问题
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
回答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.
回答2:
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);
来源:https://stackoverflow.com/questions/24626473/android-l-take-flash-image-with-autofocus-using-camera2-api