# uvccamera **Repository Path**: rumeng/uvccamera ## Basic Information - **Project Name**: uvccamera - **Description**: uvccamera 的简单应用封装 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2020-11-02 - **Last Updated**: 2023-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # uvccamera #### 介绍 uvccamera 的简单应用封装 #### 使用说明 1. 创建对象 new UVCCameraProxy(this); 2. 设置显示的view setPreviewTexture(textureView); 3. 获取设备存在的USB摄像头对象 getUsbCameraDevice(); 4. 判断摄像头是否有权限 requestPermission(usbDevice) 5. 连接摄像头 connectDevice(usbDevice) 6. 打开摄像头 openCamera() 7. 设置摄像头数据回调 setCallBackPreview(callBackPreview) 8. 开启预览 startPreview(width, height); 9. 停止预览 stopPreview(); 10. 注销摄像头以及USB断开连接 .onDestroy() 备注: xml中需要将view保存在LinearLayout中,方便将view拓展显示到自己预期的大小(解决成像上压缩) ``` ``` 代码中: ``` /*获取设备屏幕的宽度 针对竖屏pad*/ int width = this.getWindowManager().getDefaultDisplay().getWidth(); /*根据摄像头数据宽高参数与屏幕宽,计算对应的显示高*/ int viewWidth = (int) (((double) this.width * width) / height); /*重新设置显示view的宽高*/ ViewGroup.LayoutParams layoutText = textureView.getLayoutParams(); layoutText.height = width; layoutText.width = viewWidth; textureView.setLayoutParams(layoutText); /*设置旋转的角度*/ textureView.setRotation(270); int vX = -(viewWidth - width) / 2; /*设置平移的位置*/ textureView.setTranslationX(vX); /*左右镜像*/ textureView.setScaleY(-1); ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)