Incorrect orientation on 180 phone rotations when setOutputImageRotationEnabled(true) is enabled

13 views
Skip to first unread message

Javier Gerardo Martinez Salomon

unread,
Feb 16, 2026, 1:45:00 PM (23 hours ago) Feb 16
to Android CameraX Discussion Group
Hello CameraX team,

First of all, thanks for this amazing library, I'm currently using CameraX 1.4.0 and my primary use case is the analysis of images to select one given a set of conditions. 

Normally, I handle the orientation changes as per the best practices and adjust the orientation of the selected frame as per `rotationDegrees` which allows me to handle every case of rotation and device orientation.

I've been exploring the use of the setOutputImageRotationEnabled API to simplify my logic which fixes the orientation of the frame to always match the display orientation, as a result, the `rotationDegrees` are always 0 regardless of how the device is being held, this works in almost all cases, I noticed that when doing a 180 degree rotation for example, from Landscape Left to Landscape Right without triggering an activity reconstruction, the `ImageProxy` objects continue to report 0 rotation degrees, but the contents of the image do not match the reported rotation.

I tested it in the CameraXBasic sample too with the same results, building the use case like this:
imageAnalyzer = ImageAnalysis.Builder()
    // We request aspect ratio but no resolution
    .setTargetAspectRatio(screenAspectRatio)
    // Set initial target rotation, we will have to call this again if rotation changes
    // during the lifecycle of this use case
    .setTargetRotation(rotation)
    .setOutputImageRotationEnabled(true)
    .build()
    // The analyzer can then be assigned to the instance
    .also {
        it.setAnalyzer(cameraExecutor, LuminosityAnalyzer(requireContext()) { luma ->
        })
    }

I believe that the issue is, that on a landscape left orientation, the device would normally return images with 0 rotation degrees, but when rotating to landscape right it would output the images with 180 rotation degrees(upside-down), I can handle this rotation correctly when not using `setOutputImageRotationEnabled` but when it's enabled, the reported rotation is 0, while my example is for landscape rotation, this could also affect portrait/reverse portrait.

Questions:
  • Is there something I'm doing wrong to handle these cases?
  • Is this a limitation of the feature or a known issue?
  • Is there a workaround for making setOutputImageRotationEnabled work in all cases?
  • Assuming I can't get it to work, is there a utility that would allow me to rotate the YUV_420_888 if I decided to handle it myself by disabling setOutputImageRotationEnabled?
Thanks in advance
Reply all
Reply to author
Forward
0 new messages