Re: [camerax-developers] Callback to know when exactly the image gets captured

315 views
Skip to first unread message

Eino-Ville Talvala

unread,
Apr 9, 2022, 8:32:49 PM4/9/22
to Mohit Shetty, Android CameraX Discussion Group
Hi Mohit -

If your capture path produces an ImageProxy, then you can look at the timestamp in its ImageInfo: https://developer.android.com/reference/androidx/camera/core/ImageInfo?hl=en#getTimestamp()

That timestamp will be the timestamp of the start of image exposure, in nanoseconds. Unfortunately, I'm not sure if there's an easy way to tell what the timebase of that timestamp is, via CameraX, since it depends on the timestamp source for the camera device.  

So it's either measured like uptimeMillis() or like elapsedRealtime(), depending on the reported timestamp source, I believe.

Regards,

- Eddy



On Sat, Apr 9, 2022 at 1:58 PM Mohit Shetty <shetty...@gmail.com> wrote:
Is there any way/callback to know when exactly a picture is taken (after it's actually taken and before it's processed [and saved])?

This can be really helpful while developing a camera app (to snap the preview at the right moment) instead of doing it too early (right before calling ImageCapture.takePicture) or late (ImageCapture.OnImageSavedCallback/OnImageCapturedCallback's respective sucess methods). The OnImageCapturedCallback's onCaptureSuccess method could still have some delay.

--
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/2a97e4a3-176b-4d26-833c-de8c0677c034n%40android.com.

Mohit Shetty

unread,
Apr 10, 2022, 3:48:27 AM4/10/22
to Android CameraX Discussion Group, Eino-Ville Talvala, Android CameraX Discussion Group, Mohit Shetty
Hi Eino-Ville,

Actually we're trying to perform some operation precisely when the image is taken by the camera (possible with the help of a callback). In our case, we're trying to snap the preview (a short animation) exactly when the camera takes the picture. I'm not really sure if there is any way to achieve this with what the library currently offers, but please do let me know if a feature request would be required for the same.

Thanks a lot for the help and support!

Regards,
Mohit

Eino-Ville Talvala

unread,
Apr 21, 2022, 4:14:22 AM4/21/22
to Mohit Shetty, Android CameraX Discussion Group
Hi Mohit -

You're right, I don't believe CameraX currently offers a callback that could be used to trigger a shutter animation or similar.  The relevant camera2 callback would be onCaptureStarted, and though you can hook into that via the Camera2 interop classes, I'm not sure you have a reliable way to tell when the callback is fired for the JPEG capture versus just preview frames.

- Eddy

Scott Nien

unread,
Apr 21, 2022, 9:46:03 PM4/21/22
to Eino-Ville Talvala, Mohit Shetty, Android CameraX Discussion Group
Hi Mohit, 
I've filed a public bug to track this new feature https://issuetracker.google.com/230039680
I think this features seems useful and we will see if we can add it in CameraX 1.2 

Scott

Quentin Hébert

unread,
Apr 29, 2022, 6:47:58 AM4/29/22
to Android CameraX Discussion Group, scot...@google.com, shetty...@gmail.com, Android CameraX Discussion Group, etal...@google.com
Hello Mohit, Eddy and Scott,

After seeing your conversation, I've looked into the camera2 onCaptureStarted / onCaptureCompleted callbacks that can be accessed though the Camera2Interop class.
It seems to me that the CONTROL_CAPTURE_INTENT key that can be retrieved on the CaptureRequest / CaptureResult in these callbacks has a different value following if the callback is called for a capture or for a preview frame (CONTROL_CAPTURE_INTENT_STILL_CAPTURE or CONTROL_CAPTURE_INTENT_PREVIEW).

Could this be used in the meantime, until a more appropriate API is available, to determine when the image gets captured ? Or is there some cases / devices where this solution would not work ?

Thanks,

Quentin

Scott Nien

unread,
May 3, 2022, 12:03:30 AM5/3/22
to Quentin Hébert, Android CameraX Discussion Group, shetty...@gmail.com, etal...@google.com
Hi Quentin, 

Yes, you can definitely use Camera2Interop the way you suggested to tell if it is from still capture or preview.  But keep in mind that the behavior could change if ZSL is added in the future or when video capture is bound (the template could change to TEMPLATE_VIDEO_SNAPSHOT). 
 

Mohomad Mohomad

unread,
Aug 18, 2022, 4:35:45 PM8/18/22
to Scott Nien, Eino-Ville Talvala, Mohit Shetty, Android CameraX Discussion Group

Mohomad Mohomad

unread,
Aug 18, 2022, 4:51:34 PM8/18/22
to Eino-Ville Talvala, Mohit Shetty, Android CameraX Discussion Group

yihao wu

unread,
Sep 24, 2022, 2:06:55 AM9/24/22
to Android CameraX Discussion Group, mmoho...@gmail.com, shetty...@gmail.com, Android CameraX Discussion Group, etal...@google.com
When will this feature come out? I hope to get some 3A parameters after taking the photo. Could you please call back the CaptureResult of the photo result for me

Android CameraX Discussion Group

unread,
Sep 25, 2022, 10:40:28 PM9/25/22
to Android CameraX Discussion Group, Android CameraX Discussion Group
There's no public timeline at this moment. I've cc'ed you in the feature tracker, and you'll get update once it's completed. Thanks!
Reply all
Reply to author
Forward
0 new messages