CameraX image capture very slow to succeed

1,283 views
Skip to first unread message

Mohammad Sajib Al Seraj

unread,
Jul 7, 2022, 10:55:16 AM7/7/22
to Android CameraX Discussion Group

When I try to capture an image using CameraX it takes a long time compared to camera/camera2 capture. I tried with different phone, it’s not a hardware performance issue. 

Android CameraX Discussion Group

unread,
Jul 7, 2022, 5:22:50 PM7/7/22
to Android CameraX Discussion Group, mals...@mtu.edu
Hi Mohammad,

Thanks for writing in - we'll need a few more details to help:
  1. Which device(s) are you using and what are the capture times with CameraX vs Camera2?
  2. Which apps are you using to test capture times between CameraX and Camera2? The apps have the pipeline and settings will affect capture times.
The best way to compare would be to use our Timing Test App (you can build from source here: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:camera/integration-tests/timingtestapp/) which will test Camera1, Camera2, and CameraX. This would be the preferred way to judge capture times between the various APIs.

Thanks,
-Eric

mohammad aljammali

unread,
Jul 7, 2022, 9:36:29 PM7/7/22
to Android CameraX Discussion Group, Android CameraX Discussion Group, Mohammad Sajib Al Seraj
Hi all, 

I am just adding my experience. the only thing I could find that affects the speed of cameraX in a meaningful way is jpeg quality.

and I remember camera2 had a similar setting so make sure they are the same. 


 // ImageCapture
imageCapture = ImageCapture.Builder()
// .setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
.setJpegQuality(85)
// We request aspect ratio but no resolution to match preview config, but letting
// CameraX optimize for whatever specific resolution best fits our use cases
.setTargetAspectRatio(screenAspectRatio)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(rotation)
.build()

 
setCaptureMode also change the jpeg quality but the currently available options CAPTURE_MODE_MAXIMIZE_QUALITY and  CAPTURE_MODE_MINIMIZE_LATENCY  difference 
so little.  ( I think 10-20 milliseconds from a total of 200-250 milliseconds)
I think CAPTURE_MODE_MAXIMIZE_QUALITY set it to 95 and CAPTURE_MODE_MINIMIZE_LATENCY set it to 90.



Scott Nien

unread,
Jul 7, 2022, 10:01:47 PM7/7/22
to mohammad aljammali, Android CameraX Discussion Group, Mohammad Sajib Al Seraj
Hi, 

Did you set the ViewPort or use CameraController ?

If so,  software cropping and re-encoding might take some while and it would be more significant on low end devices.   Can you also share how much difference you observed ?


--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/b5fb41c6-6b53-4f40-b0b7-82afbe17cda0n%40android.com.

Mohammad Sajib Al Seraj

unread,
Jul 8, 2022, 10:17:22 AM7/8/22
to Android CameraX Discussion Group

1.    Which device(s) are you using and what are the capture times with CameraX vs Camera2? – Samsung Galaxy A50(SM-A505U1) and Galaxy S10+(SM-G975U1)

2.    Which apps are you using to test capture times between CameraX and Camera2? The apps have the pipeline and settings will affect capture times. – I tried with my company app (BiometricID app). App with CameraX is taking an average 7 seconds to capture a photo whereas Camera API is taking average 2 seconds.

Thanks
Mohammad

Mohammad Sajib Al Seraj

unread,
Jul 8, 2022, 10:25:51 AM7/8/22
to Scott Nien, Android CameraX Discussion Group
Did you set the ViewPort or use CameraController ? I am not using ViewPort, but I am using cameraControl
Camera2CameraControl.from(camera.getCameraControl()).setCaptureRequestOptions(new CaptureRequestOptions.Builder()
.setCaptureRequestOption(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF )
.setCaptureRequestOption(CaptureRequest.SENSOR_SENSITIVITY, iso)
.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_INCANDESCENT)
.setCaptureRequestOption(CaptureRequest.SENSOR_EXPOSURE_TIME, (long)(shutterSpeed*1000000000))
.build());

My app with CameraX is taking an average of 7 seconds to capture a photo whereas Camera API is taking an average of 2 seconds.

Thanks
Mohammad

Mohammad Sajib Al Seraj

unread,
Jul 8, 2022, 10:46:44 AM7/8/22
to mohammad aljammali, Android CameraX Discussion Group
This helps to improve the performance. Thanks a lot.

Mohammad Sajib Al Seraj

unread,
Jul 8, 2022, 10:53:13 AM7/8/22
to Android CameraX Discussion Group
I figured out the reason for the performance degradation. When I set flash mode ON, the performance is drastically degrading. I don't need flash mode turned ON, so I am removing flash mode for now.
imageCapture = new ImageCapture.Builder()
.setFlashMode(ImageCapture.FLASH_MODE_ON)
Thank you everyone for the valuable comments. 

Thanks
Mohammad

Scott Nien

unread,
Jul 10, 2022, 11:33:34 PM7/10/22
to Mohammad Sajib Al Seraj, Android CameraX Discussion Group
Thanks Mohammad, 

I think overriding CameraX to manual AE mode (AEMode = OFF) with flash mode ON is the root cause of this 7 seconds delay because it will never reach the AE converged state. 

We will fix the issue. 

Scott




--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.

Mohammad Sajib Al Seraj

unread,
Jul 11, 2022, 12:56:04 PM7/11/22
to Scott Nien, Android CameraX Discussion Group
Ok, thanks. 
Reply all
Reply to author
Forward
0 new messages