ImageAnalysis data is different to preview

114 views
Skip to first unread message
Assigned to charco...@google.com by wuj...@google.com

ALLEN X

unread,
Feb 13, 2023, 4:31:55 AM2/13/23
to Android CameraX Discussion Group
My device is Xiaomi13.  
Both ImageAnalysis and preview use the same resolution 1920*1080.
When I use the front DEFAULT_FRONT_CAMERA ,the data obtained from ImageAnalysis is not different to what can I see on the previewView.

Charcoal Chen

unread,
Feb 14, 2023, 3:50:18 AM2/14/23
to Android CameraX Discussion Group, 2401...@qq.com
Hi,
Thanks for reporting this issue. Can I clarify with you for some questions?

1. Does this issue only happen in the front camera but not in the back camera?
2. We don't have Xiaomi 13 device. Can this issue be reproduced on some other devices?
3. Do both Preview and ImageAnalysis get 1920x1080 stream finally? (You might be able to get the info by getResolutionInfo() -> getResolution())
4. Is it possible to provide some images to show the differences between Preview and ImageAnalysis?

Thanks.

ALLEN X

unread,
Feb 14, 2023, 9:47:47 PM2/14/23
to Android CameraX Discussion Group, charco...@google.com, ALLEN X
Hi, thanks for reply.
The following is the answer:
1.Yes. It only happen in the front camera.
2.I don't have too much devices, so I can only reproduced this issue on Xiaomi13.
3.Yes.  The resolution get by  getResolutionInfo() -> getResolution()  are both 1920x1080.
4.I can attach  a video. In this video, the top half is the previewView (scaleType is fitcenter) and bottom half is the bitmap converted by imageProxy from imageAnalysis. You can see although they have  the same resolution, the bottom half is like preview cropping the part of center region.
Screenrecorder-2023-02-15-10-39-02-609.mp4

ALLEN X

unread,
Feb 23, 2023, 4:24:36 AM2/23/23
to Android CameraX Discussion Group, ALLEN X, charco...@google.com
Have you found any solutions?

Charcoal Chen

unread,
Feb 28, 2023, 9:13:30 PM2/28/23
to Android CameraX Discussion Group, 2401...@qq.com, Charcoal Chen
Thanks for providing the information and sorry for the late reply because the notification mail was incorrectly categorized as trash mail and I was not aware of it.

This might be a device specific issue which happens on specific resolution or resolutions of specific aspect ratio. For this issue, what we can do is to add a quirk to avoid using the problematic resolutions. But I'll need your help to provide some more information so that we can add the quirk in CameraX library.
1. Does the issue only happen on 1920x1080 resolution? Or it also happens on some other or all 16:9 resolutions?
2. Does this issue only happen on 4:3 resolutions? (setting the target resolution as 1280x960 or other supported 4:3 resolutions)
3. When you find some resolutions that do not have this problem, could you also double-check that All the images among ImageCapture, Preview and ImageAnalysis are the same? (want to confirm whether the issue only affect ImageAnalysis only)
4. Does the device have newer OS build to update? If yes, please update it and see whether this issue can be resolved.

Thanks. 

Ansar Zafar

unread,
Mar 2, 2023, 11:59:25 PM3/2/23
to Android CameraX Discussion Group, charco...@google.com, 2401...@qq.com
hi! I hope everyone is doing good here!
when I captured the i want bitmap and don't want to save it in the local storage so how can i get that bitmap???

Charcoal Chen

unread,
Mar 3, 2023, 3:07:02 AM3/3/23
to Ansar Zafar, Android CameraX Discussion Group, 2401...@qq.com
Please try the following steps:

1. Use this ImageCapture#takePicture() API to receive the captured ImageProxy via OnImageCapturedCallback.
2. Refer to the jpegImageToJpegByteArray() function to get the JPEG byte array.
3. Use BitmapFactory#decodeByteArray to decode the JPEG byte array.
4. Maybe show the result on an ImageView in the test app
Reply all
Reply to author
Forward
0 new messages