UVCCamera的显示接口未释放导致页面初始化冲突 release_interface:release interface failed
com.lyq.uvccamerademo E/libusb/usbfs: [10592*android_usbfs.c:1776:release_interface]:release interface failed, error -1 errno 22
com.lyq.uvccamerademo E/UVCCamera: [10592*UVCCamera.cpp:172:connect]:could not open camera:err=-99
摄像头初始化
private void initCamera() {
UvcCamera.getInstance().init(this);
// 初始化摄像头
for (int i = 0; i < mUvcCameraSum; i++) {
CameraViewInterface uvcCameraInterface1 = null;
CameraViewInterface uvcCameraInterface2 = null;
switch (i) {
case 0:
uvcCameraInterface1 = (CameraViewInterface) Cone.findViewById(R.id.uvc_camera_0);
if (null != uvcCameraInterface1) UvcCamera.getInstance().initCamera(uvcCameraInterface1, vmcDataCallBack1);
break;
case 1:
uvcCameraInterface2 = (CameraViewInterface) findViewById(R.id.uvc_camera_1);
if (null != uvcCameraInterface2) UvcCamera.getInstance().initCamera(uvcCameraInterface2, vmcDataCallBack2);
break;
}
}
// 需要时间初始化摄像头,Surface等,否则无返回数据(无画面)
mDelayHandler.postDelayed(mCameraRunnable, 800);
}
这里需要 注意delay的时间够不够: mDelayHandler.postDelayed(mCameraRunnable, 800);
/**
* lambda => UVC摄像头图像回调
*/
Bitmap bitmap1 = null;
private UvcCameraDataCallBack vmcDataCallBack1 = data -> {
if (InfraredCameraLock == false) {
byte[] data1 = null;
data1 = data;
bitmap1 = tra.createBitmap_from_byte_alpha_data(UVCCamera.DEFAULT_PREVIEW_WIDTH, UVCCamera.DEFAULT_PREVIEW_HEIGHT, data1);
Mat src = new Mat();//调用opencv方法新建一个Mat对象
//Bitmap转换为Mat
Utils.bitmapToMat(bitmap1, src);
Utils.matToBitmap(src, bitmap1);
}
};
issue参考 https://github.com/saki4510t/UVCCamera/issues
|