When I switch cameras using Android, this error occurs.
This is my code for switching cameras.
public void switchCam(){
javaCameraView.disableView();
if(isFrontCamera){
// javaCameraView.setCameraIndex(CameraBridgeViewBase.CAMERA_ID_FRONT);
lockCamId = Camera.CameraInfo.CAMERA_FACING_BACK;
javaCameraView.setCameraIndex(lockCamId);
isFrontCamera = false;
}else{
lockCamId = Camera.CameraInfo.CAMERA_FACING_FRONT;
javaCameraView.setCameraIndex(lockCamId);
isFrontCamera=true;
}
javaCameraView.enableView();
}
I will first use this to start my camera
JavaCameraView javaCameraView = new JavaCameraView(context,CameraBridgeViewBase.CAMERA_ID_ANY);
Of course, I also thought of using CameraBridgeViewBase.CAMERA_ID_FRONT or CameraBridgeViewBase.CAMERA_ID_BACK
This way, it is more likely to trigger errors in the title. How should I correctly and reasonably switch cameras
At first, this code ran normally, but when I unplugged the USB camera or replaced it (when exiting the application), I would receive an error message with the title .Attempting to restart the application or Android device cannot effectively resolve the issue.
OpenCVSDK 4.9.0