Android Camera.autoFocus and FOCUS_MODE_CONTINUOUS_PICTURE

I have a camera app that allows the user to take pictures. On my main screen, I have a camera created on SurfaceView. When the user takes a photo, I call camera.autoFocus and in the AutoFocusCallback callback I call camera.takePicture. Then I save the photo and move on to another event to view the photo. I call camera.stopPreview () when exiting the camera page (onPause) and camera.startPreview () when returning (onResume).

The camera is initialized with FOCUS_MODE_CONTINUOUS_PICTURE. I don’t recycle the camera, returning to the camera page (since this is a slow operation that takes ~ 2 seconds), but just call startPreview if the camera was initialized before.

Here is my problem. Before the first photo, continuous autofocus works fine, because FOCUS_MODE_CONTINUOUS_PICTURE is initially set to the camera. However, after calling the camera.autoFocus function, the FOCUS_MODE_CONTINUOUS_PICTURE function stops working. Later, when I return to the same screen and call startPreview, continuous autofocus no longer works.

Is there a way to restart continuous autofocus without rebooting the camera? I would like to avoid restarting the camera, as this causes a few seconds of delay for the user.

+6
source share
1 answer

I fixed the problem by calling the camera.cancelAutoFocus () function. This caused continuous autofocus to re-enable.

+17
source

All Articles