Bugreport: camerax on android emulator with virtual scene produces slightly distorted images for image analyzation

73 views
Skip to first unread message

Christian Günther

unread,
Dec 9, 2022, 7:28:09 AM12/9/22
to Android CameraX Discussion Group
I am running an image analyzation use-case with configuration visible here:
https://issuetracker.google.com/issues/261111885?pli=1

Nevertheless i want to describe here an issue that seems to be bound just to the android emulator. The example images attached to the post are captured using the code from the references bug-report but from emulator. 

used camera-x version: 1.2.0

I am running the following android-sdk stack:
```
./sdkmanager --list
Installed packages:=====================] 100% Computing updates...            
  Path                                                  | Version      | Description                                | Location                                            
  -------                                               | -------      | -------                                    | -------                                              
  build-tools;29.0.3                                    | 29.0.3       | Android SDK Build-Tools 29.0.3             | build-tools/29.0.3                                  
  build-tools;30.0.2                                    | 30.0.2       | Android SDK Build-Tools 30.0.2             | build-tools/30.0.2                                  
  build-tools;30.0.3                                    | 30.0.3       | Android SDK Build-Tools 30.0.3             | build-tools/30.0.3                                  
  build-tools;31.0.0                                    | 31.0.0       | Android SDK Build-Tools 31                 | build-tools/31.0.0                                  
  build-tools;32.0.0                                    | 32.0.0       | Android SDK Build-Tools 32                 | build-tools/32.0.0                                  
  build-tools;33.0.0                                    | 33.0.0       | Android SDK Build-Tools 33                 | build-tools/33.0.0                                  
  build-tools;33.0.1                                    | 33.0.1       | Android SDK Build-Tools 33.0.1             | build-tools/33.0.1                                  
  emulator                                              | 31.3.13      | Android Emulator                           | emulator                                            
  ndk;25.1.8937393                                      | 25.1.8937393 | NDK (Side by side) 25.1.8937393            | ndk/25.1.8937393                                    
  patcher;v4                                            | 1            | SDK Patch Applier v4                       | patcher/v4                                          
  platform-tools                                        | 33.0.3       | Android SDK Platform-Tools                 | platform-tools                                      
  platforms;android-29                                  | 5            | Android SDK Platform 29                    | platforms/android-29                                
  platforms;android-31                                  | 1            | Android SDK Platform 31                    | platforms/android-31                                
  platforms;android-32                                  | 1            | Android SDK Platform 32                    | platforms/android-32                                
  platforms;android-33                                  | 2            | Android SDK Platform 33                    | platforms/android-33                                
  sources;android-33                                    | 1            | Sources for Android 33                     | sources/android-33                                  
  system-images;android-30;google_apis_playstore;x86    | 9            | Google Play Intel x86 Atom System Image    | system-images/android-30/google_apis_playstore/x86  
  system-images;android-30;google_apis_playstore;x86_64 | 10           | Google Play Intel x86 Atom_64 System Image | system-images/android-30/google_apis_playstore/x86_64
```

The emulator device was created using this call:

```
yes | /opt/android-sdk/cmdline-tools/latest/bin/avdmanager create avd -n x86_64-device -k "system-images;android-30;google_apis_playstore;x86_64" -b x86_64 -c 100M --device "Nexus 6P"
```

I start the emulator with:
```
emulator -avd x86_64-device -no-snapshot -camera-front none -camera-back virtualscene -netfast -wipe-data -no-audio -no-boot-anim
```

The emulator provides correct looking camerax preview and correct looking camerax capture. But the camerax analysis-use case produces the slightly distorted images as in the attachment. The behavior is the same no matter if OUTPUT_IMAGE_FORMAT_YUV_420_888 with java side yuvToRGB conversion or OUTPUT_IMAGE_FORMAT_RGBA_8888 is with camerax side libyuv conversion is used. The images does look exactly the same.

Did maybe anyone run integration tests also for image analysis use-cases for the emulator and and countered maybe same problems here? Is there maybe a quirk in specifc emulator versions?
tf_inputsdk_gphone_x86_64_Dec 9, 2022 12:57:12 PM.png
tf_input_unprocessedsdk_gphone_x86_64_Dec 9, 2022 12:57:12 PM.png

Android CameraX Discussion Group

unread,
Dec 11, 2022, 9:39:44 PM12/11/22
to Android CameraX Discussion Group, christian...@authentic.network
Thanks for the post. We have replied the issue in the bug. Let's continue discussing there!

Hector Zepeda

unread,
Dec 11, 2022, 9:42:32 PM12/11/22
to Android CameraX Discussion Group
Start the emulator

--
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/a57edb9d-855b-4a61-8235-35ffd94fb9d6n%40android.com.
--
null

Hector Zepeda

unread,
Dec 11, 2022, 9:43:48 PM12/11/22
to Android CameraX Discussion Group
Having problems 

--
null

Christian Günther

unread,
Dec 12, 2022, 5:13:37 AM12/12/22
to Android CameraX Discussion Group, zepedah...@gmail.com
Again, i was using the wrong answer button -.-

shortly again. Two point i see here.

1. Try to confirm that the emulator is working fine with the "virtual scene" configuration for the back-faced camera. This can already be done by starting the system camera on the emulator without any own app-dev. This should validate you that the virtual camaera, hardware-accelelration and gpu-libs of the emulator host are correctly loaded and configured to do all the streaming capabilities.

2. There exists and bug in the emulator not beeing able to call the camera capture. The emulator-team is aware of the problem but seemed to miss the merge of the fix. Nevertheless i was able to validate that it is still working on older emulation image with API 30:
https://issuetracker.google.com/issues/161034252#comment11

Maybe as a side-note. If you want to add android-emulator based integration tests regarding to specific input images, you can place a plane in front of the virtual camera containing a specific image. This can be done by adding the plane to the Toren1BD.posters file of the emulator like this:
```
[...]

poster custom
size 2 2
position 0 0 -0.75
rotation 0 0 0
default custom.png
```

Christian Günther

unread,
Dec 12, 2022, 8:22:55 AM12/12/22
to Android CameraX Discussion Group, Christian Günther, zepedah...@gmail.com
I applied the libyuv camerax based conversion with additional row-stride compensation as discussed here:
https://issuetracker.google.com/issues/261111885#comment3

The result keeps exactly the same. So it seems to me, that the emulator based image-analysis yuv stream is already borked.

Christian Günther

unread,
Dec 13, 2022, 5:20:19 AM12/13/22
to Android CameraX Discussion Group, Christian Günther, zepedah...@gmail.com

I like to create the issue maybe also directly on the emulator side, but it seems that i don't have the access rights to place a bug report there. Can anybode help me out with that?
https://issuetracker.google.com/issues/new?component=192727

best,
Christian
Reply all
Reply to author
Forward
0 new messages