第45讲 手动对焦实战 - Android Camera2 API

2024年10月27日 第45讲 手动对焦实战 极客笔记

本讲是Android Camera专题系列的第45讲,我们介绍Android Camera2 API专题的手动对焦实战。

更多资源:

资源 描述
在线课程 极客笔记在线课程
知识星球 星球名称:深入浅出Android Camera
星球ID: 17296815
Wechat 极客笔记圈

手动对焦(Manual Focus)

判断手动对焦是否支持

  • LENS_INFO_MINIMUM_FOCUS_DISTANCE是否大于0
  • CameraControllerManager2#printFocusCapability

设置AF Mode为OFF

GeekCamera代码逻辑

PopupView
|--> Preview#updateFocus
|----> Preview#setFocusValue
|------> CameraController2#setFocusValue //更新Focus Mode或Focus Distance
|--------> CameraSettings#setFocusMode
|--------> CameraSettings#setFocusDistance
|------> CameraController2#setRepeatingRequest

调整Focus Distance

ManualFocusSeekbar#onProgressChanged // ManiActivity
|--> Preview#setFocusDistance
|----> CameraController2#setFocusDistance
|------> CameraSettings#setFocusDistance
|------> CameraController2#setRepeatingRequest

setFocusDistance

private void setFocusDistance(CaptureRequest.Builder builder) {
    if( MyDebug.LOG )
        Log.i(TAG, "[AF_Practise] setFocusDistance change focus distance to " + focus_distance);
    builder.set(CaptureRequest.LENS_FOCUS_DISTANCE, focus_distance);
}

本文链接:http://so.lmcjl.com/news/16323/

展开阅读全文