Status Update
Comments
er...@google.com <er...@google.com>
br...@gmail.com <br...@gmail.com> #2
hu...@google.com <hu...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
br...@gmail.com <br...@gmail.com> #4
Attached are screenshots from a Nexus 10 emulator running Android R. The only changes from the master branch in the CameraXBasic project are the one's to update to the latest dependencies (see:
A team member did run into this issue on a Zebra ET51 as well. We have not tried running on an actual Nexus 10.
The stretching issue did get resolved. It was tracked here (
hu...@google.com <hu...@google.com> #5
I see.
When the device is in a portrait orientation, the captured image should also have the same orientation. I'll test on other tablets, but until I'm able to reproduce the issue, it'll be hard to figure out what's going wrong.
Does the issue reproducible on other emulators?
br...@gmail.com <br...@gmail.com> #6
The issue does not reproduce on a Nexus 7 emulator running Android R. It also does not reproduce on a Pixel C emulator running Android R.
br...@gmail.com <br...@gmail.com> #7
Hi,
This is bug is a major blocking issue for my project, so I've been digging deeper into this issue. One thing that I noticed while investigating is the fact that the latest Nexus 10 emulator is reporting an incorrect natural orientation. To my best knowledge, the default orientation of the Nexus 10 is landscape. As is the Zebra ET51. Most phone's default orientation is portrait.
The place in the sample app where we access the display's orientation is android.view.Surface.Rotation
it states:
/**
* Rotation constant: 0 degree rotation (natural orientation)
*/
public static final int ROTATION_0 = 0;
So, for the Nexus 10, when the device is in landscape, I would expect ROTATION_0
to be returned when I call val rotation = viewFinder.display.rotation
. However, for some reason, the code is returning ROTATION_1
. I believe this emulator bug is masking the true bug for CameraX. I can file a new emulator bug if y'all want.
The true bug for CameraX here is: When the device's default orientation is landscape (not portrait), the camera preview does not match the final photo's orientation.
hu...@google.com <hu...@google.com> #8
Hi Bryan,
I tested on a Pixel C tablet running Android R emulator, and it does indeed return a different rotation value (ROTATION_1
) than expected when it's in its natural orientation (landscape). The physical Pixel C device returns ROTATION_0
. Another interesting thing though is that the camera sensor orientation on a physical Pixel C device is 0, while it's 90/270 (back/front) on a Pixel C emulator. So it seems to even out with the ROTATION_1
.
I'd recommend testing more on a physical device, you may run into unexpected issues on emulators, and this might be the cause of the issue you're seeing.
br...@gmail.com <br...@gmail.com> #9
I ended up buying an actual Nexus 10 to debug this issue. The photos have the correct orientation. Attached are pictures (the wood figurines).
For the Zebra ET-51, I did a little more digging and realized a little more of what was actually happening here. Initially, the preview looked "zoomed in", but after setting the attribute app:scaleType="fitCenter"
on PreviewView
, it became clear that the orientations of the preview and the photo actually do match. However, the rotation is incorrect. Attached are pictures (the dogs).
hu...@google.com <hu...@google.com> #10
Hi Bryan,
Glad to see the issue on the Nexus 10 has been resolved. It seems your emulator had an issue.
Regarding the Zebra tablet, are the preview and capture results different from the native camera app?
br...@gmail.com <br...@gmail.com> #11
The Zebra tablet's native camera has the correct orientation for the preview and the actual photo (ie. holding the tablet in portrait results in a portrait preview and portrait photo, holding the tablet in landscape results in a landscape preview and landscape photo).
br...@gmail.com <br...@gmail.com> #12
While we are waiting on a fix, I contacted Zebra and their engineers have helped us find a solution I can tolerate. TO BE CLEAR: THIS IS STILL A BUG AND Y'ALL SHOULD FIX IT. But my ability to assist in any debugging is soon ending, so if y'all want me to provide any more help, it is now or never. Our current band-aid solution requires device specific code and does not fully meet our expectations, but it is better than before.
It seems like setting a target aspect ratio for both the preview and the resulting photo do not behave properly for the Zebra ET51. When we do not set the target aspect ratio, it appears as though CameraX will default to a 4:3 aspect ratio. Thankfully, it is oriented correctly for the ET51. So while we still do have decent mismatch between the screen's aspect ratio and the camera's aspect ratio, the difference is less than before. Attached are some pictures for reference. The photos are using the CameraXBasic
sample app with a patch (also attached) applied.
TL;DR: do not use setTargetAspectRatio()
for the Zebra ET51 tablet
ch...@google.com <ch...@google.com> #13
For the Nexus 10 device, actually the result is still incorrect but it is not so obvious as the ET51 device. By the provided capture photo in
For the ET51 tablet device, I think it should support some portrait sizes. The bug in SupportedSurfaceCombination.java#376 would cause those portrait sizes to be selected in priority.
The workaround mentioned in
ch...@google.com <ch...@google.com>
ku...@walmart.com <ku...@walmart.com> #15
Just wanted to let ya'll know that when we updated to the latest library versions found setTargetAspectRatio()
or not. Attached is the preview using the latest library versions. When we reverted back to 1.0.0-beta07 & 1.0.0-alpha14, the workaround described in
ch...@google.com <ch...@google.com> #16
Thanks for providing the information. In the latest 1.0.0-beta08 release, we do some cleanup related to the default aspect ratio setting . The default aspect ratio now is also the same as calling setTargetAspectRatio(). For this buganizer issue, we're working on a CL to fix the target aspect ratio issue on tablets and it is targeted to be included in the next release. Please refer to
To confirm the issue root cause is exactly the same as what I analyzed in
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);
StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Size[] outputSizes = map.getOutputSizes(ImageFormat.PRIVATE);
ku...@walmart.com <ku...@walmart.com> #17
Thanks so much. We have used the code snippet provided and gathered the information you need. We believe that the first array is the back camera and the second array is the front camera for the ET51 Tablet:
[4160x3120,4000x3000,3840x2160,3264x2448,3200x2400,2976x2976,2592x1944,2688x1512,2048x1536,1920x1080,2560x800,1600x1200,1440x1080,1280x960,1280x768,1280x720,1200x1200,1280x480,1280x400,1024x768,800x600,864x480,800x480,720x480,640x480,640x360,480x640,480x360,480x320,352x288,320x240,240x320,176x144,160x120,144x176]
[2592x1944,2048x1536,1920x1080,2560x800,1600x1200,1440x1080,1280x960,1280x768,1280x720,1200x1200,1280x480,1280x400,1024x768,800x600,864x480,800x480,720x480,640x480,640x360,480x640,480x360,480x320,352x288,320x240,240x320,176x144,160x120,144x176]
ch...@google.com <ch...@google.com> #18
ap...@google.com <ap...@google.com> #19
Branch: androidx-master-dev
commit f7601b432650179fe0e780e603d0bfbc7328b9f1
Author: charcoalchen <charcoalchen@google.com>
Date: Mon Aug 24 15:16:23 2020
Fix target aspect ratio issue on tablet devices
Whether the sensor orientation is landscape should not be determined by the sensor orientation degrees value. Using SENSOR_INFO_PIXEL_ARRAY_SIZE value to determine it.
Relnote:"Fixed target aspect ratio issue on tablet devices. A 16:9 size should be selected when the target aspect ratio is set as AspectRatio.RATIO_16_9."
Bug: 151969438
Test: ./gradlew bOS
Change-Id: Ib7fcfae000fb16010c2246f22a7e6f6efb8021aa
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
M camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
Description
CAMERA APPLICATION NAME AND VERSION: CameraXBasic (
ANDROID OS BUILD NUMBER: 8.1.0
DEVICE NAME: Nexus 10 Emulator, Zebra ET51
DESCRIPTION: When the tablet preview is portrait oriented, the resulting photo is landscape.
STEPS TO REPRODUCE:
1. Put the tablet in portrait
2. Launch the demo app
3. Take a picture
OBSERVED RESULTS: Resulting photo is landscape
EXPECTED RESULTS: Resulting photo is portrait
REPRODUCIBILITY: 5 of 5
ADDITIONAL INFORMATION: There might be an associated bug: