ImageCapture.setFlashMode not working

375 views
Skip to first unread message
Assigned to leoh...@google.com by wuj...@google.com

re.le...@gmail.com

unread,
Aug 7, 2020, 10:12:39 AM8/7/20
to Android CameraX Discussion Group
Hello!

Note: I am using Camera2Interop options as well. Tested on 3 phones, without difference, so it must be code problem.

I have troubles with FlashMode, setting this used to work. However for some reason i cant get it to fire when set to ON. 
I tried setting all 3A options to AUTO etc. 
I tried hardcoding ON on ImageCapture builder when building use-cases, not even that worked. It used to work fine even when dynamically set via switch statement. 
There are no errors, or anything like that it just does not fire flash when I set it to ON. 

Here are list of CaptureRequest options I am using as default values:
CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION , 0 
CaptureRequest.CONTROL_AWB_MODE,  CaptureRequest.CONTROL_AWB_MODE_AUTO
CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO
CaptureRequest.CONTROL_AE_MODE,  CaptureRequest.CONTROL_AE_MODE_ON
CaptureRequest.EDGE_MODE,  CaptureRequest.EDGE_MODE_HIGH_QUALITY

Thanks for help.




Leo Huang

unread,
Aug 7, 2020, 10:48:58 PM8/7/20
to Android CameraX Discussion Group, re.le...@gmail.com
Hi,

Thanks for reporting this issue. May I know have you changed the the CameraX version? If yes, from which version to which?

Could you try to remove the Camera2Interop options and test again?

The AE_MODE option "CaptureRequest.CONTROL_AE_MODE,  CaptureRequest.CONTROL_AE_MODE_ON"  will override the option from FlashMode.On, that is CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH.

In the current design, Camera2Interop has higher priority than CameraX's function (maybe start from certain CameraX version). Actually it is not recommended to config AF/AE/AWB mode via Camera2Interop since CameraX will control them. Basically they are already AF/AWB_AUTO and AE_ON mode in most cases, so maybe you don't have to set them.


re.le...@gmail.com 在 2020年8月7日 星期五下午10:12:39 [UTC+8] 的信中寫道:

re.le...@gmail.com

unread,
Aug 10, 2020, 4:47:50 AM8/10/20
to Android CameraX Discussion Group, leoh...@google.com, re.le...@gmail.com
Hi, 

Thank you for fast response. I tried your solution.
The solution partially solved the problem. It seems that CONTROL_AE_MODE is causing issues. When i remove CONTROL_AE_MODE key from CaptureRequest, flash is working. However, if I want to use  SENSOR_EXPOSURE_TIME to set exact exposure time, I have to set CONTROL_AE_MODE to CONTROL_AE_MODE_OFF, as soon as I add  that key,  flash from CameraX is not triggering any more. Same is for ISO options, in order for them to work i have to set CONTROL_AE_MODE_OFF and i lose ability to trigger flash.
As for versions:
This was done on 05beta and after issues I tried 07beta. Unfortunately I am not sure anymore if it was working on 03beta. But i was using 03beta for very short time. I think it might not be version problem but CONTROL_AE_MODE key is disabling me from using flash.

Leo Huang

unread,
Aug 11, 2020, 11:33:02 AM8/11/20
to Android CameraX Discussion Group, re.le...@gmail.com, Leo Huang

The CONTROL_AE_MODE_ON seems to conflict with the usage of SENSOR_EXPOSURE_TIME and ISO (SENSOR_SENSITIVITY) which require the AE_MODE to be OFF.

I tried a little bit to enable flash and take picture with exposure time on some devices. The behavior vary, most of them will turn off the "fired" flash and then start image capture with the given exposure time.

I am wondering if you really want to do this? and will CameraControl.enableTorch() meet your requirement?

Or do you just want your app have multiple functions in a single camera UI session?

i.e. User can take picture with flash ON, or user can take picture with given exposure time, the functions my not be used at the same time but they are all in the same camera UI session.

If so, unfortunately, Camera2Interop currently does not yet support dynamic setting options after the UseCase is created.

A possible workaround is to rebind a new ImageCapture with new Camera2Interop when switching the functions. However, due to the re-creation of the CaptureSession, the preview may freeze for a short period of time.

re.le...@gmail.com 在 2020年8月10日 星期一下午4:47:50 [UTC+8] 的信中寫道:

re.le...@gmail.com

unread,
Aug 13, 2020, 5:01:48 AM8/13/20
to Android CameraX Discussion Group, leoh...@google.com, re.le...@gmail.com
Hi,
I want user to be able to select multiple options in one session, before capture happens. It is not such a huge problem if exposure and iso disable flash, so its fine. 

It seems that exposure compensation can work with flash unit, so it might be a workaround if user want to have both flash and higher exposure. 
As for dynamic setting, I know. With setting of each option I get preview reset because of unbinding. I hope there will be option for dynamic option setting in near future.

Leo Huang

unread,
Aug 14, 2020, 8:59:23 AM8/14/20
to re.le...@gmail.com, Android CameraX Discussion Group
Glad to hear that. I believe the "exposure compensation" and "dynamic Camera2Interop" will be supported also in the near future. Stay tune!

re.le...@gmail.com <re.le...@gmail.com> 於 2020年8月13日 週四 下午5:01寫道:
Reply all
Reply to author
Forward
0 new messages