4

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.

Alexandre Marcondes
  • 5,859
  • 2
  • 25
  • 31
Maxim Metelskiy
  • 1,389
  • 14
  • 29
  • It's not clear what you want to do. Are you using manual exposure but want to turn the flash on for focusing, or just want the flash to fire for the final capture? Or something else entirely? Right now you're both firing a single flash and trying to trigger AF in one request, which is unlikely to work. – Eddy Talvala Jan 07 '15 at 23:22
  • I want to make flash fired for focusing and for final capture. Like "flash on" mode of google camera app – Maxim Metelskiy Jan 09 '15 at 03:47
  • If you're using AE_MODE_OFF, you'll have to manually manage the flash, which is only possible in a limited way currently. You'll need to switch the flash to TORCH before you start focusing, and then set it to SINGLE for your high-resolution capture. – Eddy Talvala Jan 09 '15 at 21:33
  • Thank you, @Eddy! I thought about this way. But it looks like a hack. Is it really, that "Flash always on" is so complicated feature with using camera2 API? – Maxim Metelskiy Jan 11 '15 at 14:53

1 Answers1

2

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);
yydcdut
  • 801
  • 6
  • 9
  • Thanks for reply! I forgot to mention, that I need flash light always, not auto. And I'm not sure about "setRepeatingRequest". Touch focus is just single action. And last question: can I manage work of flash by FLASH_MODE parameter, not by CONTROL_AE_MODE? – Maxim Metelskiy Dec 23 '14 at 20:35
  • FLASH always ON: mBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH); – yydcdut Dec 24 '14 at 00:58
  • "setRepeatingRequest" means "request endlessly repeating capture of images by this capture session“ in SDK document. – yydcdut Dec 24 '14 at 01:01
  • I don't need torch. I need flash always on as camera mode. It means, that flash must be fired only for each capturing and each focusing. But it shouldn't depends from light conditions. – Maxim Metelskiy Dec 25 '14 at 01:54
  • I tried to use TEMPLATE_MANUAL. My problem is that I can't understand the difference between CONTROL_AE_MODE and FLASH_MODE. What differences between them? What FLASH_MODE is responsible for? – Maxim Metelskiy Dec 25 '14 at 07:59
  • mPreviewBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH); – yydcdut Jan 04 '15 at 10:00