Android auto focus when continuous auto focus modes are not supported

后端 未结 2 2048
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 06:42

I have a camera in my app and I want to make it auto focus continuously in the same way that the phone\'s camera does it. I found the modes FOCUS_MODE_CONTINUOUS_VIDEO

相关标签:
2条回答
  • 2020-12-30 06:51

    I got a similar pb on my samsung S4 and I solved it with:

    camera.setParameters(parameters);
        camera.autoFocus(null);
    

    This is suggest in the Google doc here.

    To make the camera parameters take effect, your application has to call setParameters(Camera.Parameters).

    0 讨论(0)
  • 2020-12-30 07:11

    We had a requirement to support a very wide range of phones. My solution in the end was to handle each case differently.

    For the scenario of phones without continuous auto-focus support I implemented a utility to listen to the accelerometer using SensorManager and trigger mCamera.autoFocus(...) whenever the user moves the camera.

    There were also some older tablets that only supported fixed focus (who would use such a thing!), in that case the picture needed to be taken immediately - not on the focus callback.

    For most modern phones the code snippet above was fine to use FOCUS_MODE_CONTINUOUS_PICTURE.

    0 讨论(0)
提交回复
热议问题