Android Camera.autoFocus and FOCUS_MODE_CONTINUOUS_PICTURE

断了今生、忘了曾经 提交于 2019-12-04 22:18:07

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/23357121/android-camera-autofocus-and-focus-mode-continuous-picture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!