How to keep the photos or videos taken by the front camera consistent with the preview

346 views
Skip to first unread message

Hong Wang (LazyIonEs)

unread,
Nov 22, 2023, 7:04:26 AM11/22/23
to Android CameraX Discussion Group
When using CameraX, the photos or videos taken with the front camera are upside down with the preview interface. How can I keep them consistent with the preview?

tonyt...@google.com

unread,
Nov 23, 2023, 12:27:54 AM11/23/23
to Android CameraX Discussion Group, lazy...@gmail.com
Hi,
Thanks for the question. For front camera, the preview will be mirrored horizontally. There might be an orientation issue if you see it upside down. May we know what device you tested?


For video, there's [VideoCapture.Builder.setMirroMode](https://developer.android.com/reference/androidx/camera/video/VideoCapture.Builder#setMirrorMode(int)) that could mirror the video.

Hong Wang (LazyIonEs)

unread,
Nov 23, 2023, 2:06:55 AM11/23/23
to Android CameraX Discussion Group, tonyt...@google.com, Hong Wang
For users, the preview will be mirrored horizontally, which is normal. This is also my current situation, but the photos and videos taken are inconsistent with the preview and are not mirrored. My test device is RMX33770

Hong Wang (LazyIonEs)

unread,
Nov 23, 2023, 2:07:32 AM11/23/23
to Android CameraX Discussion Group, Hong Wang, tonyt...@google.com
Thanks for your reply, VideoCapture.Builder.setMirroMode works for me, but for OutputFileOptions.Builder.setMetadata I have a question, when I set isReversedHorizontal = true, and when shooting with front, I am using glide The effect of loading the image is indeed consistent with the preview, but when I use BufferedOutputStream to copy the file to another directory, when I open it in the photo album, it is indeed upside down and rotated 90 degrees, which is for my users It may be unacceptable. How should we solve this problem?

tonyt...@google.com

unread,
Nov 23, 2023, 2:36:01 AM11/23/23
to Android CameraX Discussion Group, lazy...@gmail.com, tonyt...@google.com
Yes, by default the image/video will not be mirrored so that the objects, such as texts, will appear in correct direction.

So for image capture, currently the mirroring is applied by setting EXIF orientation. The image content isn't altered regardless of isReversedHorizontal. In your case, my guess is that the EXIF orientation isn't copied correctly or the album app doesn't take EXIF orientation into account correctly.

Hong Wang (LazyIonEs)

unread,
Nov 23, 2023, 2:40:07 AM11/23/23
to Android CameraX Discussion Group, tonyt...@google.com, Hong Wang
Your guess is correct, the system's photo album application does not properly consider the EXIF direction. When I use glide to display this photo within the application, the EXIF direction remains consistent with the preview.
Reply all
Reply to author
Forward
0 new messages