I have a proprietary device with a rotated camera, that doesn't report its rotation to the OS.
We use CameraX
with PreviewView
, and I get the image 90 deg rotated, and mirrored.
Is there an efficient way to rotate the preview?
We tried:
- Setting the setTargetOrientation of camera, of analyzer, of Preview. None works.
- Rotating the
PreviewView
of course doesn't work, it just modifies the ViewPort because it won't rotate the surface. ViewFinder
library - outputs bitmaps but doesn't connect toPreview
(or does anybody have a solution for that?). WithoutsetSurfaceProvider
, nothing will empty the frames pipeline, and it will display nothing.
Ugly "Solution":
We currently use bitmap (via Analyzer), then we display the bitmap. That's ugly, and CPU expensive.
Is Camera2 the only way to rotate previews nicely? Camera2 does bitmaps anyway, but it may do the YUV conversion on hardware.
NOTE
Solutions like here don't work. Setting target orientation of the Preview only modifies the scale to compensate for aspect ratio. It doesn't actually rotate. Also that doesn't work because it's obsolete and not valid anymore.