Ask Your Question
0

OpenCV4Android - Changing Camera Focus Mode

asked 2013-02-06 03:01:32 -0600

EMGRobotics gravatar image

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();
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-02-06 11:36:40 -0600

See on Tutorial-5 example in OpenCV4Android SDK. It demonstrates how to implement custom camera control. It shows how to turn on camera color effects and change camera resolution. You can change focus mode in the same way.

edit flag offensive delete link more

Comments

I noticed in OpenCV 2.4,3,2 file SampleJavaCameraView.java there are methods for getEffect(), setEffect(), getResolution() and setResolution()

I do not see anything concerning focus. I thought maybe focus could be set using the setEffect() method but that does appear to be possible.

Are you saying I should add a getFocus() and setFocus() method? If so, I will using the resolution and effect as a model and will submit the change to the OpenCV team.

EMGRobotics gravatar imageEMGRobotics ( 2013-02-06 16:18:08 -0600 )edit

Sample demonstrates how to implement custom camera control using OpenCV SDK classes. The main idea is to inherit from JavaCameraView or NativeCameraView class and implement any customization you want. For example, you can overload initializeCamera method and it will be used instead the same method in the base class.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-02-06 23:57:12 -0600 )edit

Question Tools

Stats

Asked: 2013-02-06 03:01:32 -0600

Seen: 3,968 times

Last updated: Feb 06 '13