how to set and get iso and exposure time when capturing picture?

1,308 views
Skip to first unread message

Bob Smith

unread,
Nov 20, 2020, 4:35:10 AM11/20/20
to Android CameraX Discussion Group
when using camera2 api,I can set Iso and exposure time without  closing and reopening camera.
But in camerax api,I have to use camera2interop to set Iso and exposure time.This will cause  closing and reopening camera,which may spend a bit of time.
Would you please tell me is there any way that I can set set Iso and exposure time without closing and reopening camera?


Also,with camera2 api,I can get them from CaptureResult.get(CaptureResult.SENSOR_SENSITIVITY);

But I cannot find function simmalr in camerax api.Is there anyway I can get them? 

Thanks a lot

TY Chang

unread,
Nov 20, 2020, 7:11:12 AM11/20/20
to Android CameraX Discussion Group, lss19...@gmail.com
We understand requiring reopening camera in order to apply different Camera2 parameters could be difficult. And we are considering different approach that allows applications to do that dynamically.

For monitoring capture result, now there's Camera2Interop#setSessionCaptureCallback which can be used to attach CaptureCallback and then it works just like Camera2. Hope it helps!

Aurel Megnigbeto

unread,
Nov 25, 2020, 2:20:32 PM11/25/20
to Android CameraX Discussion Group, tonyt...@google.com, lss19...@gmail.com
Please, I have the same issue and I'm wondering where and how to set the Camera2Interop#setSessionCaptureCallback.
Here is what I did so far:

val imageAnalyzerBuilder = ImageAnalysis.Builder()

camera2InterOp = Camera2Interop.Extender(imageAnalyzerBuilder)

camera2InterOp?.setSessionCaptureCallback(object: CameraCaptureSession.CaptureCallback() {

    override fun onCaptureCompleted(
        session: CameraCaptureSession,
        request: CaptureRequest,
        result: TotalCaptureResult
    ) {
        super.onCaptureCompleted(session, request, result)
    }
})

// ImageAnalysis
imageAnalyzer = imageAnalyzerBuilder
    .setTargetAspectRatio(screenAspectRatio)
    .setTargetRotation(rotation)
    .build()

My issue is that when the preview starts, the callback is called repeatedly before the picture is taken and the "result" variable does not have useful data.

successfox tao

unread,
Nov 26, 2020, 8:01:29 AM11/26/20
to Android CameraX Discussion Group, megni...@gmail.com, tonyt...@google.com, lss19...@gmail.com
https://android-review.googlesource.com/c/platform/frameworks/support/+/1310574
It seems that Google CameraX team has changed the Camera2InterOp. we can set the parameters dynamically.
I think this change would be release in beta13 in Dec.

megni...@gmail.com 在 2020年11月26日 星期四上午3:20:32 [UTC+8] 的信中寫道:

Scott Nien

unread,
Nov 26, 2020, 9:50:18 PM11/26/20
to successfox tao, Android CameraX Discussion Group, megni...@gmail.com, tonyt...@google.com, lss19...@gmail.com
Yes,   the new Camera2Interop API that allows dynamically setting parameters will be added in December release.  

Regarding getting CaptureResult for ImageCapture takePicture ,  unfortunately it is not supported. 
Aurel,  
can you tell us why do you need this capability ?   It will help us plan the missing features.   Thanks 


--
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/b59ecedd-c7ea-4d42-af7b-90120c9c0e6bn%40android.com.

Aurel Megnigbeto

unread,
Nov 27, 2020, 7:18:40 AM11/27/20
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, Aurel Megnigbeto, tonyt...@google.com, lss19...@gmail.com, succe...@gmail.com

Thank you for your reply.
Actually, I want to get properties like CaptureRequest.SENSOR_SENSITIVITY or  CaptureRequest.SENSOR_EXPOSURE_TIME on the captured picture. With camera2 api, I have access to CaptureResult to perform those extractions. That is why I want something like CaptureResult for camerax.
Thank

successfox tao

unread,
Nov 29, 2020, 10:00:58 PM11/29/20
to Android CameraX Discussion Group, megni...@gmail.com, Scott Nien, Android CameraX Discussion Group, tonyt...@google.com, lss19...@gmail.com, successfox tao
Since now we can not get ISO or exposure time from CaptureRequest,  I think you can temporarily get the ISO or exposure from the JPEG's exif. ^^

megni...@gmail.com 在 2020年11月27日 星期五下午8:18:40 [UTC+8] 的信中寫道:

megni...@gmail.com

unread,
Nov 30, 2020, 12:20:52 AM11/30/20
to successfox tao, Android CameraX Discussion Group, Scott Nien, tonyt...@google.com, lss19...@gmail.com
Yes, I have thought about that solution and I'm wondering if it will
not be too slow, read the exif from the stored image on the disk.
Anyway I'll show a loader to the user while I'm extracting the exif as
I don't want to run this instruction on background.

Thank you.

Scott Nien

unread,
Dec 3, 2020, 2:41:06 AM12/3/20
to megni...@gmail.com, successfox tao, Android CameraX Discussion Group, tonyt...@google.com, lss19...@gmail.com

How about using ByteArrayOutputStream for OutputFileOption. This way you get the jpeg buffer in memory. 

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputFileOptions = new ImageCapture.OutputFileOptions.Builder(outputStream).build();

Aurel Megnigbeto

unread,
Dec 3, 2020, 5:01:27 AM12/3/20
to Android CameraX Discussion Group, Scott Nien, succe...@gmail.com, Android CameraX Discussion Group, tonyt...@google.com, lss19...@gmail.com, Aurel Megnigbeto

It looks good. I'll try it.

Richard Kirk

unread,
Jun 6, 2022, 4:01:03 AM6/6/22
to Android CameraX Discussion Group, megni...@gmail.com, Scott Nien, succe...@gmail.com, Android CameraX Discussion Group, tonyt...@google.com, lss19...@gmail.com
Did it work? I am trying to make a colour measuring app. I have a stream of preview images, and I would like to make a live display of the colour and light levels. It would be good to have the corresponding exposure and white balance settings.
Reply all
Reply to author
Forward
0 new messages