ImageAnalysis not emitting new images

459 views
Skip to first unread message

Igor Bozin

unread,
Sep 8, 2020, 7:44:14 AM9/8/20
to Android CameraX Discussion Group
Hello, 

I have following problem: On some devices (specifically, i have tested on the Zebra TC75), the ImageAnalysis does not emit any images. I get following error log:

W/CameraX-core_ca: type=1400 audit(0.0:375): avc: denied { read } for name="u:object_r:camera_prop:s0" dev="tmpfs" ino=12392 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:camera_prop:s0 tclass=file permissive=0

W/System.err:     at example.camera.CameraXController.lambda$setAnalyzer$3$CameraXController(CameraXController.java:198)

W/System.err:     at example.camera.-$$Lambda$CameraXController$A99t3ycq_5uX1IDpj-iYU0iyJRA.analyze(Unknown Source:4)

It does work on a Oneplus 6 though, what could be the problem?

Best regards,

Igor

Scott Nien

unread,
Sep 8, 2020, 10:43:10 PM9/8/20
to Igor Bozin, Android CameraX Discussion Group
Hi Igor,  
The logs are not enough,   can you share more logs ?  
Also, while ImageAnalysis does not emit any images,  preview is working , right ?  



--
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/16a3376e-0664-408b-8b0e-b8ce5d142cd8n%40android.com.

Igor Bozin

unread,
Sep 9, 2020, 4:39:48 AM9/9/20
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, Igor Bozin
Hello Scott,

I have made some progress in the meantime: It seems that for some reason, ImageAnalysis does not select the next best possible resolution. In my source code i set it like this:

Size imageSize = new Size(1080, 1920);
imageAnalysis = new ImageAnalysis.Builder().setTargetResolution(imageSize).setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST).build();

If i change the Size to 640 x 480 , i get images again, although I am sure that this is not the next best available camera resolution (the device should be capable of taking 720p images).
I have also noticed that if I dont specify any resolution at all, CameraX selects for the image analysis always the 640x480 resolution, even on the Oneplus 6, which can use 1920x1080 if i set it explicitly through setTargetResolution.  (the preview is working fine, although i also think it has a lower resolution than 1920x1080)

Is there any way to know in advance what the available resolutions are and how to automatically select the best possible? I would actually like to avoid having specified values and always take the highest available one. (Maybe through a method like get

Also, is there a way to get the resolution of the imageAnalysis  other than setting the analyzer and then taking it from the image proxy? Currently, the getAttachedSurfaceResolution methods are restricted to the camera X library only, but it would be useful to have the ability to get the actual resolution of the images emitted to the analyzer and the resolution of the preview.

Thank you very much in advance;

Best regards,

Igor

Charcoal Chen

unread,
Sep 9, 2020, 10:54:03 PM9/9/20
to Igor Bozin, Android CameraX Discussion Group, Scott Nien
Hi Igor,

It looks like there were frames captured by the ImageAnalysis and passed to your analyzer. Therefore, the "CameraXController$A99t3ycq_5uX1IDpj-iYU0iyJRA.analyze()" callback was called to pass an ImageProxy object to your app. Could you help to check and provide more info about what the "Unknown Source:4" could possibly be? Did the issue happen when doing some operations on the received ImageProxy object?

About the target resolution setting, please refer to the javadoc of setTargetResolution() API:

The maximum available resolution that could be selected for an ImageAnalysis is limited to be under 1080p. The limitation of 1080p for ImageAnalysis has considered both performance and quality factors so that users can obtain reasonable quality and smooth output stream under 1080p.

If not set, resolution of 640x480 will be selected to use in priority.

If your app prefers a higher resolution, you may be able to do the setting as the following:
  • setTargetResolution(1080, 1920) if your app prefers a 16:9 size.
  • setTargetResolution(1080, 1440) if your app prefers a 4:3 size.
By this approach, CameraX will try to select the largest supported size under 1080P according to the aspect ratio of your setting.

About the other question, could you describe more why you need to obtain the selected resolution before obtaining the ImageProxy object?

Igor Bozin

unread,
Sep 11, 2020, 3:06:55 AM9/11/20
to Android CameraX Discussion Group, charco...@google.com, Android CameraX Discussion Group, Scott Nien, Igor Bozin
Hello Charcoal,
I have found out a couple of more things:
You were right, the problem actually occured from operations on the ImageProxy object, I was converting the Image from it to a RGB image and it seems that there is for some reason trouble when converting images of certain resolutions. I had no trouble with the conversion of 1920x1080 images, but 1440x1080 was giving me wrong images.

Here is what I mean, I get this when i set 1440x1080 to the image analysis and do my conversion to RGB :

Screenshot from 2020-09-11 08-51-09.png

And this ( its not sharp, but you get the point) when setting 1920x1080 to image analysis:

Screenshot from 2020-09-11 08-51-35.png


Here is a gist with my conversion code:

https://gist.github.com/igorbozin/31ba8cc07df0b905e4124f65cf2c318e

Do you maybe have a clue where this comes from?


For the second part: I am trying to implement the analyzer to be able to use it for object recognition. I have a box overlay over the image, which tells the user where to put the object to be able to scan it  and I am trying to set the focus of the camera to be directed to this part of the image. Since we have different resolutions for the preview and the image analysis, I need to do some scaling (since the coordinates of the cutout box on the preview aren't the same as on the actual image I am anaylsing) and I would like to be calculate the scaling factors before I actually run the image analysis for the first time. Also I want to draw some overlay graphics on the canvas back again to give the user feedback that his object is getting recognized.


Best regards,

Igor

Eino-Ville Talvala

unread,
Sep 11, 2020, 12:39:29 PM9/11/20
to Igor Bozin, Android CameraX Discussion Group, charco...@google.com, Scott Nien
From a very quick look, you're not using the value of Image.Plane#getRowStride() anywhere, so your calculation of totalWidthLandscape will be wrong - it needs to basically be equal to the row stride, and will be different for each plane.

Scott Nien

unread,
Sep 14, 2020, 2:43:00 AM9/14/20
to Eino-Ville Talvala, Igor Bozin, Android CameraX Discussion Group, charco...@google.com

Igor Bozin

unread,
Sep 15, 2020, 3:14:09 AM9/15/20
to Android CameraX Discussion Group, Scott Nien, Igor Bozin, Android CameraX Discussion Group, charco...@google.com, Eino-Ville Talvala
Hello all,

Thank you very much for the answers!  I will try this out and give feedback if it helped to solve the issue.

Best regards,

Igor
Reply all
Reply to author
Forward
0 new messages