Manual focus with flash using Android camera2

5.9k views Asked by At

How to perform manual (Touch) focus with flash using Android camera2 api?

My captureRequest settings are: 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

usage:

CaptureSession.capture(captureRequest.build(), captureCallback, null);

Result: Camera get focused if there is enough light. Otherwise flash blinks very fast and focus fails.

1

There are 1 answers

6
yydcdut On BEST ANSWER

you can try to perform manual (Touch) focus with flash by this way:

mPreviewBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);

when use TRIGGER,use both AE and 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);

and then:

mCameraCaptureSession.setRepeatingRequest(mPreviewBuilder.build(), mPreviewSessionCallback, mHandler);