I am trying to capture a picture using the android Camera2 Api. Everything is working quite well. However, there is a problem that I am facing. So, when my app loads up, the torch is turned on during the preview session. But my goal is when I take the photo, the torch doesn't go off. Right now, when I take a photo , it switches to flash mode and then back to torch mode. I don't want it to flash and rather the torch stays on during the camera capture. How do I go about it?
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
if(autoflashstate==0){
//turn on torch
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE,
CameraMetadata.FLASH_MODE_TORCH);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS,
new MeteringRectangle[]{focusAreaTouch});
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS,
new MeteringRectangle[]{insideFocusAreaTouch});
}
/* else{
//turn off flash light and then turn on torch
unlockAutoFlash(mPreviewRequestBuilder);
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[]{focusAreaTouch});
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[]{insideFocusAreaTouch});
}*/
Do you set the FLASH_MODE to TORCH in your still capture request as well?
Also make sure your AE_MODE is just ON, not ON_AUTO_FLASH or ON_ALWAYS_FLASH, since those override the FLASH_MODE setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With