如何使用camera2 api在android中自动捕获照片? api 21及以上版本没有像onAutoFocused()那样的回调。
答案 0 :(得分:1)
您必须手动触发AF和AE。 标准管道是:
CONTROL_AF_TRIGGER
设置为CONTROL_AF_TRIGGER_START
中用于预览的CaptureRequest.Builder
,并通过CameraCaptureSession capture
方法提交给会话。调用捕获后,请记住在CaptureRequest.Builder中将CONTROL_AF_TRIGGER
重置为CONTROL_AF_TRIGGER_IDLE
进行预览; CaptureResult.CONTROL_AF_STATE of TotalCaptureResult
是否为CONTROL_AF_STATE_FOCUSED_LOCKED || CONTROL_AF_STATE_NOT_FOCUSED_LOCKED || CONTROL_AF_STATE_PASSIVE_FOCUSED || CONTROL_AF_STATE_PASSIVE_UNFOCUSED
CONTROL_AE_PRECAPTURE_TRIGGER
中触发AE设置CONTROL_AE_PRECAPTURE_TRIGGER_START
至CaptureRequest.Builder
,并通过CameraCaptureSession capture
方法提交至会话。调用捕获后,请记住在CaptureRequest.Builder中将CONTROL_AE_PRECAPTURE_TRIGGER
重置为CONTROL_AE_PRECAPTURE_TRIGGER_IDLE
进行预览; CaptureResult.CONTROL_AE_STATE of TotalCaptureResult
是否为CONTROL_AE_STATE_CONVERGED || CONTROL_AE_STATE_FLASH_REQUIRED || CONTROL_AE_STATE_LOCKED
我也有经验可以同时触发AF e AE(步骤1-3)并同时等待它们(步骤2-4)。