如何使用Android camera2 api用闪光灯进行手动(触控)对焦?
我的captureRequest设置是: 1. type - TEMPLATE_PREVIEW 2. CONTROL_AE_MODE - CONTROL_AE_MODE_OFF 3. FLASH_MODE - FLASH_MODE_SINGLE 4. CONTROL_AF_TRIGGER - CONTROL_AF_TRIGGER_START
用法:
CaptureSession.capture(captureRequest.build(), captureCallback, null);
结果: 如果有足够的光线,相机会聚焦。否则闪光灯会快速闪烁并且对焦失败。
答案 0 :(得分:2)
您可以尝试通过这种方式使用闪光灯进行手动(触摸)对焦:
mPreviewBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
使用TRIGGER时,同时使用AE和AF:
mPreviewBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
mPreviewBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
mPreviewBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START);
然后:
mCameraCaptureSession.setRepeatingRequest(mPreviewBuilder.build(), mPreviewSessionCallback, mHandler);