Landscape preview orientation issue

44 views
Skip to first unread message

Taylor Stephenson

unread,
Mar 16, 2023, 3:48:57 PM3/16/23
to Android CameraX Discussion Group
Hi,


We are having an issue where the preview changes rotation when tilt the phone sideways/landscape. It is only an issue with preview, the capture comes out in the correct orientation and with the full aspect ratio, but it is hard for users to tell what they are going to capture.

This is specific to certain devices. I attached an image of the native camera and our app on the same phone to compare.

It might be similar to huawei meteX2, preview on landscape has wrong rotation. [262114753] - Visible to Public - Issue Tracker (google.com), but I'm not sure. And I don't know what I need to change to get it working.

Info:
- Spectralink Versity 9540
- Android 8.1.0
- CameraX 1.1.0 and 1.2.0
- our app's layouts are screenOrientation = portrait

Our OrientationListener set the same values for preview.targetRotation on a working and not working device.

ImplementationMode.COMPATIBLE didn't seem to make a difference.


Appreciate any help,
Taylor
wrong_rotation.jpg
correct_rotation.jpg

Scott Nien

unread,
Mar 17, 2023, 12:03:24 AM3/17/23
to Taylor Stephenson, Android CameraX Discussion Group
Can you share how you set the targetRotation in the  OrientationListener?  
I think you probably don't need to set any targetRotation in Preview as it is mainly for some special cases.  


--
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/1fd100be-3eab-41ae-8279-caaee3eaeadfn%40android.com.

Taylor Stephenson

unread,
Mar 17, 2023, 9:11:40 AM3/17/23
to Android CameraX Discussion Group, scot...@google.com, Android CameraX Discussion Group, Taylor Stephenson
I tried not setting preview.targetRotation and it seems to have resolved the issue. Thanks!


We set targetRotation like this: CameraX use case rotations  |  Android Developers.  Except it was set for Preview & ImageCapture because those are our use cases. We were trying to support the "Locked Orientation" case from this table: 

I guess I misunderstood the documentation and thought I should also set it for the preview use case.

Scott Nien

unread,
Mar 19, 2023, 11:01:00 PM3/19/23
to Taylor Stephenson, Android CameraX Discussion Group
Glad that it worked!
Looks like the documentation can do better to avoid the issue you ran into.  We will see how we can improve it. Thanks for letting us know. 

Reply all
Reply to author
Forward
0 new messages