1

Following camera2basic guide on Android L preview page, I am able to capture normal images, i.e. without flash or using auto-focus mechanism (I rely on passive focus)

However, I would like to take a flash image. The documentation states before taking flash image, I should call android.control.aePrecaptureTrigger to determine correct exposure.

My question:

  • How can I call AE Precapture trigger, wait for it to complete and then take the image using capture(CaptureRequest, CameraCaptureSession.CaptureListener, Handler)?

Method I've already tried:

  • After user clicks capture image button, I start a preview
  • Set CONTROL_AE_PRECAPTURE_TRIGGER to CONTROL_AE_PRECAPTURE_TRIGGER_START
  • Monitor AE_STATE result in CaptureListener's onCaptureCompleted method
  • When AE_STATE converges, I set AE lock and take image using capture() method

However, the flash image is still over-exposed and sometimes, I get complete garbage image.

Has anyone able to get this working?

Once this is working, auto-focus mechanism can be used in similar fashion.

Thanks

VP.
  • 1,200
  • 13
  • 20

2 Answers2

1

Thanks for trying out the new camera2 API!

You shouldn't need to lock AE; once you see AE_STATE as CONVERGED (or FLASH_REQUIRED), submit the still capture request.

Things to verify:

  • Is your AE_MODE either ON_AUTO_FLASH or ON_ALWAYS_FLASH for both the preview and the still capture requests? If not, the metering routines won't be controlling flash power or firing correctly. The still capture and preview templates may just have AE mode set to ON, which means the flash won't be fired under AE control.
  • Are you using CAPTURE_INTENT_STILL_PICTURE for the still capture? If not, the flash won't be fired by the automatics. This is automatically set for TEMPLATE_STILL_CAPTURE.

If you're seeing garbage images, please feel free to file a bug on our Android AOSP tracker: http://b.android.com

Detailing the set of outputs you have for your session would be especially helpful, since we know there are some current bugs for certain output Surface sets.

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47
  • When I set AE_MODE to ON_ALWAYS_FLASH, it doesn't take flash image. This is my request to camera: -> Create capture builder with TEMPLATE_STILL_CAPTURE -> CONTROL_CAPTURE_INTENT to CONTROL_CAPTURE_INTENT_STILL_CAPTURE -> CONTROL_MODE to CONTROL_MODE_AUTO -> CONTROL_AE_MODE to CONTROL_AE_MODE_ON_ALWAYS_FLASH. However, no image is never taken with flash. – VP. Jul 10 '14 at 05:33
  • Is your preview request's AE mode also ON_ALWAYS_FLASH, especially during the precapture sequence? – Eddy Talvala Sep 13 '14 at 20:10
  • Sorry, but as far as i understand you related with camera2API development, maybe you can help me to solve very specific issue, i have explained it here http://stackoverflow.com/questions/40327476/why-does-flash-drives-app-in-stack-camera2api?noredirect=1#comment67913022_40327476 Thank in advance! – Sirop4ik Oct 30 '16 at 12:46
1

I am not sure you got answer or not. I just figure it out as follows: First I did for capturebuilder

captureBuilder.set(CaptureRequest.CONTROL_MODE,
                    CameraMetadata.CONTROL_MODE_AUTO);
captureBuilder.set(CaptureRequest.FLASH_MODE,
                    CameraMetadata.FLASH_MODE_TORCH);

I set both because I think that flash can be able to take while auto mode. But the result is can't get flash image when capture. Now I get flash image after I set boolean value for flash on/off.

 if (isFlashOn)
                captureBuilder.set(CaptureRequest.FLASH_MODE,
                        CameraMetadata.FLASH_MODE_SINGLE);
            else
                captureBuilder.set(CaptureRequest.CONTROL_MODE,
                        CameraMetadata.CONTROL_MODE_AUTO);
YeeKhin
  • 219
  • 4
  • 8
  • Hi, can you please add some more detail? Were you able to take flash image with proper precapture sequence? I mean first a pre-flash and then the main flash image? All my flash images are over-exposed. – kunal18 Mar 03 '16 at 13:02