How to disable / change AutoFocus and AutoWhiteBalance on an Android camera using OpenCV

I use Android + Opencv (new for opencv) and now I work with real-time object detection (the object remains very close to the Android Android device), and I noticed that the Android cameraโ€™s autofocus changes my appearance (โ€œzoom inโ€ effect and โ€œreduceโ€), which makes it difficult to track the object.

I need to turn off "AUTO FOCUS" because in my case the more blurry the input of the image I have, the better, and I also need to turn off AutoWhiteBalance or maybe set a different value.

I would like to know how to do this with OpenCV CameraBridgeViewBase so that I can change the settings of the Focus / WhiteBalance camera.

I am trying to find a way to solve this problem, and I noticed that many people are facing the same problems.

Here at Stack Overflow, it would be a great place to find whoever worked with it and find a good way to overcome these problems.

+4
source share
1 answer

create your own subclass javacameraview public class MyJavaCameraView extends JavaCameraView { where you can access mCamera ; Add access to the camera using the method that interests you. eg

 // Setup the camera public void setFlashMode(boolean flashLightON) { Camera camera = mCamera; if (camera != null) { Camera.Parameters params = camera.getParameters(); params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); camera.setParameters(params); 

and use this new class as part of the main action

  //force java camera mOpenCvCameraView = (MyJavaCameraView) findViewById(R.id.activity_surface_view); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); mOpenCvCameraView.enableView(); 
+2
source

All Articles