Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV4Android - Changing Camera Focus Mode

JavaCameraView sets the camera focus mode to FOCUS_MODE_CONTINUOUS_VIDEO.

For my application I would like to set the camera to FOCUS_MODE_INFINITY.

Obviously, I can simply change the library and rebuild, but that would require that I release my product as a static build ( something I would like to avoid ).

To be clear, I am not trying to change the camera focus mode after the camera is instantiated.
I just need to set the camera focus mode at init.

My questions - Is there currently a method to set the Android camera focus to infinity? Is there a current effort to add camera focus mode changing support?

thanx

JavaCameraView.java (OpenCV 2.4.3.2)

               params.setPreviewFormat(ImageFormat.NV21);
                Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
                params.setPreviewSize((int)frameSize.width, (int)frameSize.height);

                List<String> FocusModes = params.getSupportedFocusModes();
                if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
                {
                    params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
                }

                mCamera.setParameters(params);
                params = mCamera.getParameters();