CameraX orientation problem

1,521 views
Skip to first unread message

Yasser Magdad

unread,
Jul 30, 2021, 5:02:51 AM7/30/21
to Android CameraX Discussion Group
Hello
I am trying to build an app that uses CameraX, I've followed an example on medium.com written by Huseyn Hakeem, when starting the fragment I get the wrong orientation:
-on the simulator: 
  1. the view is 90 rotated
  2. the captured photo shows correctly in <ImageView/>
  3. the saved photo shows rotated 90 degrees in the gallery
-on Samsung M12: 
  1. the view correct
  2. the captured photo shows -90 degree <ImageView/>
  3. the saved photo shows correctly in the gallery
-( on the front cam same but reversed)

-Exif data always returns a rotation value of 6 and changing it done nothing
-I tried to set Manifest like these values yet still the same problem:
    android:screenOrientation="fullSensor"
    android:configChanges="orientation"
whether the rotation listener returned a value from 0 to 3 or not still can't solve it

Charcoal Chen

unread,
Aug 2, 2021, 3:51:34 AM8/2/21
to Yasser Magdad, Android CameraX Discussion Group
Hi,

I'm not sure which article on medium.com you referred to. It seems that medium.com doesn't provide a whole project written by CameraX. If there is, please provide the link and we can do further check.

Could you try the CameraXBasic sample project and check whether the same issues happen again on your simulator and Samsung M12 device? I run the CameraXBasic sample app on an Android 11.0 emulator and an Android 11.0 Samsung S20+ 5G device. The results look correct. (I updated the library dependencies to 1.0.1 for core/camera2/lifecycle modules and 1.0.0-alpha27 for camera-view.)

For the M12 results you mentioned, did you apply the exif rotation degrees when displaying the captured image in the ImageView? This might be the root cause because the saved photo can be displayed correctly in the gallery app.

For the simulator part, I can't know the possible root cause unless I can reproduce it. Maybe you can double check it by the CameraXBasic sample app or try some other different Android versions of simulators to see whether the issues still exist.

If the issues only happen under some specific settings, please also kindly provide the related information. So that we can clarify the issues. Thanks.

--
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/e1aa2783-226c-4297-884e-4ac0eaa515b6n%40android.com.

Charcoal Chen

unread,
Aug 3, 2021, 6:44:49 AM8/3/21
to Yasser Magdad, Android CameraX Discussion Group
Hi,

Thanks for providing the code. I tried to use your code to run the CameraXBasic app. The preview and the captured image results look fine on the Android 11.0 emulator and an Android 11.0 Samsung S20+ 5G device.  Because ResultFragment code was not provided, I can't see the result in ResultFragment.

To clarify whether this is a CameraX library issue or not, could you check whether the issue exists when using the app built from the original CameraXBasic code base? If possible, please provide a minimal code project which you are comfortable to provide and can reproduce the issue. If anything you think that might be related to the issue, for example, library version, android version and so on, please also let me know. That will be helpful for the issue clarification.

Please use Reply-all to make all discussions kept in the Android CameraX Discussion Group. It allows everyone of our team to know the issue status and all discussion details. Thank you.

On Tue, Aug 3, 2021 at 3:47 PM Yasser Magdad <yasser...@gmail.com> wrote:
Hi
actually, it was an article that had a link to CameraXBasic at GitHub (seems it's code got updated a little lately), I implemented the code in CameraFragment.kt except the  LuminosityAnalyzer,  volumeDownReceiver. 
tried to get the orientation while keeping the layout vertical(because the app is supposed to be only in portrait mode) and got nothing from the listener (using Toast), then changed the Manifest to fullSensore and got the values 0to3 but still nothing,
here is my Fragment and I already apologize because I am  still new and learning
I need to get a correct image no matter how the user holds the phone while keeping the layout vertical
checked multiple emulator Pixel xx versions and still the same
Thanks
Reply all
Reply to author
Forward
0 new messages