AndroidUSBCamera is developed based on the saki4510t/UVCCamera, the project of USB Camera (UVC equipment) and the use of video data acquisition are highly packaged, and it can help developers using USB Camera devices easily by a few simple APIs. By using AndroidUSBCamera,you can detect and connect to a USB Camera simply.And you also can use it to realize taking picture,recording mp4,switching resolutions and setting camera's contrast or brightness,etc.Here is some gifs of this demo:
(2)支持本地录制mp4格式视频,支持实时获取音视频数据流;
(3)支持jpg格式图片抓拍;
(4)支持获取camera支持的分辨率,和分辨率切换;
(5)支持屏蔽声音,重启Camera;
(6)支持相机自动对焦;
(7)支持调整对比度和亮度
> AndroidUSBCamera is developed based on the saki4510t/UVCCamera, the project of USB Camera (UVC equipment) and the use of video data acquisition are highly packaged, and it can help developers using USB Camera devices to connect, preview and video data collection by a few simple API. The main functions include:
(1)supports detecting USB Camera equipment, and previewing;
(2)supports recording MP4 format video, and acquiring real-time audio and video data;
To be attention,mCallback is a object of interface CameraViewInterface.Callback,and it's used to be listenering surfaceView
created or detoryed.mDevConnectListener is a object of interface UVCCameraHelper.OnMyDevConnectListener,and it's used to be listenering to detect and conntect USB device.Here is the coding order:
```java
private CameraViewInterface.Callback mCallback = new CameraViewInterface.Callback mCallback(){
@Override
@Override
public void onSurfaceCreated(CameraViewInterface view, Surface surface) {
public void onSurfaceCreated(CameraViewInterface view, Surface surface) {
if(!isPreview && mUSBManager.isCameraOpened()) {
// must have
mUSBManager.startPreview(mUVCCameraView, new AbstractUVCCameraHandler.OnPreViewResultListener() {
if (!isPreview && mCameraHelper.isCameraOpened()) {
@Override
mCameraHelper.startPreview(mUVCCameraView);
public void onPreviewResult(boolean result) {
}
});
isPreview = true;
isPreview = true;
}
}
}
}
@Override
@Override
public void onSurfaceChanged(CameraViewInterface view, Surface surface, int width, int height) {
public void onSurfaceChanged(CameraViewInterface view, Surface surface, int width, int height) {
@ -115,124 +53,64 @@ dependencies {
@Override
@Override
public void onSurfaceDestroy(CameraViewInterface view, Surface surface) {
public void onSurfaceDestroy(CameraViewInterface view, Surface surface) {
if(isPreview && mUSBManager.isCameraOpened()) {
// must have
mUSBManager.stopPreview();
if (isPreview && mCameraHelper.isCameraOpened()) {
mCameraHelper.stopPreview();
isPreview = false;
isPreview = false;
}
}
}
}
});
// 初始化引擎
mUSBManager = USBCameraManager.getInstance();
mUSBManager.initUSBMonitor(this,listener);
mUSBManager.createUVCCamera(mUVCCameraView);
```
### 3. 注册USB设备广播事件监听器,开始Camera预览
Register the USB device broadcast event listener and start the Camera Preview
```
// 注册USB事件广播监听器
if(mUSBManager != null){
mUSBManager.registerUSB();
}
// 恢复Camera预览
if(mUVCCameraView != null){
mUVCCameraView.onResume();
}
}
```
private UVCCameraHelper.OnMyDevConnectListener listener = new UVCCameraHelper.OnMyDevConnectListener() {
### 4. 注销USB设备广播事件监听器,停止Camera预览
@Override
Unregister the USB device broadcast event listener and stop the Camera Preview