Question

I have a camera app that allows the user to take pictures. On my main screen I have a camera rendered on a SurfaceView. When the user takes a photo, I call camera.autoFocus and on the AutoFocusCallback callback I call camera.takePicture. Then I save the photo and go to another activity to preview the photo. I call camera.stopPreview() when leaving the camera page (onPause), and camera.startPreview() when coming back (onResume).

The camera is initialized using FOCUS_MODE_CONTINUOUS_PICTURE. I do not recycle the camera when coming back to the camera page (since it is a slow operation that takes ~2 seconds), but just call startPreview if the camera has been initialized before.

Here is my problem. Before taking the first photo, continuous autofocus works fine since FOCUS_MODE_CONTINUOUS_PICTURE is set up initially on the camera. However after calling camera.autoFocus, FOCUS_MODE_CONTINUOUS_PICTURE stops working. Later when I return to the same screen and call startPreview, continuous auto focus does not work kick in anymore.

Is there a way to restart continuous autofocus without having to restart the camera? I'd like to avoid restarting the camera as this causes several seconds of delay for the user.

Était-ce utile?

La solution

I fixed the issue by calling camera.cancelAutoFocus(). This caused continuous autofocus to kick in again.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top