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.