How to lock focus in camera2 api, android?

前端 未结 2 443
别那么骄傲
别那么骄傲 2020-12-30 02:31

I am trying to lock focus after my custom camera finds focus. First it AF mode set to auto:

builder.set(CaptureRequest.CONTROL_AF_MODE,
                    C         


        
相关标签:
2条回答
  • 2020-12-30 03:14

    You can't locus the focus on CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE.

    You should put your AF mode on CONTROL_AF_MODE_AUTO adn wait for FOCUSED_LOCKED state during your AF trigger. You can check how the Android focus machine works on enter link description here

    0 讨论(0)
  • 2020-12-30 03:18

    In order to lock the AF you have to take care of requesting the AF_TRIGGER only once by using capture() instead of repeatingRequest() (if not it enters in an af request loop and remains always trying to focus, but some nexus fix this in its FW, so some devices as Nexus 5 focus well even it shouldn't)

    So, the correct order will be:

    • Set CONTROL_AF_MODE to CONTROL_AF_MODE_AUTO (via session.setRepeatingRequest()) and the AF_REGIONS and the AE_REGIONS if you want

    • Wait until you check that the CONTROL_AF_MODE is already in auto by checking the totalCaptureRequest from the CaptureCallback.

    • Set the AF_TRIGGER_START in the builder along with the CONTROL_AF_MODE_AUTObut this time instead of using session.setRepeatingRequest() use session.capture().

    • Inmediately after that, set the AF_TRIGGER to set the AF_TRIGGER_IDLE (not cancel!) an use again session.setRepeatingRequest() along with the CONTROL_AF_MODE_AUTO.

    • Wait until it has focused,you will receive FOCUSED_LOCKED or NOT_FOCUSED_LOCKED.

    The PASSIVE_FOCUSED state is only when the CONTROL_AF_MODE is in continuous picture not in auto!

    Take care of being really in auto focus mode before performing the trigger.

    You should use always session.capture() with all triggers (with CONTROL_AE_PRECAPTURE_TRIGGER too) but always after that remember to put the triggers to IDLE (not cancel) in a session.repeatingRequest()

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