Implement Tap to Focus in Camera2 API

后端 未结 3 1304
故里飘歌
故里飘歌 2020-12-28 20:15

i want to implement tap to focus feature in my custom camera. This is the basic code provided by Google https://github.com/googlesamples/android-Camera2Basic

Here\'s

3条回答
  •  醉话见心
    2020-12-28 20:44

    1. Use the onTouch listener to get the point where the user touch the screen.
    2. Calculate a/some MeteringRectangle(s) based on that position.
    3. Use this metering rectangles to set the CaptureRequest.CONTROL_AF_REGION & CaptureRequest.CONTROL_AE_REGION

    4. set the CaptureRequest.CONTROL_AF_MODE to CaptureRequest.CONTROL_AF_MODE_AUTO

    5. CaptureRequest.CONTROL_AF_TRIGGER to CameraMetadata.CONTROL_AF_TRIGGER_START
    6. CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER to CameraMetadata.CONTROL_AE_TRIGGER_START

    7. Then build capture request


    Here you can find a full example.


提交回复
热议问题