问题
You might consider this question a sequel to this other one I've recently asked. I have a custom device with a front camera that is mirrored by default and I would like it to always behave like it was flipped horizontally. Note that the end goal of my app is to perform face, barcode and facemask detection (the last one with a custom .tflite
model), and I'm trying to understand if it's possible with the current state of CameraX and the quirks of the device I'm using.
- For the preview, I can force
PreviewView
to use aTextureView
by callingPreviewView#implementationMode = PreviewView.ImplementationMode.COMPATIBLE
so I can just callPreviewView#setScaleX(-1)
and it gets displayed like I want. - For taking pictures, I haven't tried yet but I know I can pass
setReversedHorizontal(true)
to theImageCapture.OutputFileOptions
used in theImageCapture.Builder
, so the image should be saved in reverse. - For image analysis I really don't know. If the input image is taken directly from the preview stream, then it should still be in its default state because
PreviewView#setScaleX(-1)
only flips the View on screen, right? So in my Analyzer'sanalyze()
I would need to convert theImageProxy#image
to bitmap, then flip it and pass the result toInputImage.fromBitmap()
.
Is this everything I need? Is there a better way to do this?
来源:https://stackoverflow.com/questions/65595525/does-mirroring-the-front-camera-affect-mlkit-with-camerax