Starting from Android 13, Android supports setting Mirror for each Camera Output Stream. This article introduces the specific usage method.
从Android13开始,Android支持为每个摄像头输出流设置镜像。本文介绍了具体的使用方法
Android 13 added the following constants to the OutputConfiguration class to represent different Mirror directions:
Android13在OutputConfiguration类中添加了如下常量来表示不同的镜像方向
Constans | Value | Description |
---|---|---|
MIRROR_MODE_AUTO自动镜像模式 | 0 | Automatic mirroring based on camera facing.This is the default mirroring mode for the camera device. With this mode: The camera output is mirrored horizontally for front-facing cameras. There is no mirroring for rear-facing and external cameras.基于摄像头朝向自动镜像此模式是摄像头默认的镜像模式,该模式下:对于前置摄像头做水平镜像,对于后置摄像头或外接摄像头无镜像效果 |
MIRROR_MODE_H水平镜像模式 | 2 | Camera output is mirrored horizontally.the same behavior as in AUTO mode for front facing camera.相机输出做水平镜像,与前置摄像头在自动模式下的行为相同 |
MIRROR_MODE_NONE无镜像模式 | 1 | No mirror transform is applied.No mirroring is applied to the camera output regardless of the camera facing.不应用镜像变换无论摄像头朝向如何都不将镜像应用到摄像头输出 |
MIRROR_MODE_V垂直镜像模式 | 3 | Camera output is mirrored vertically相机输出做垂直镜像. |
Android 13 added two APIs to the OutputConfiguration class to set and get the Mirror value of the current OutputConfiguration.
Android 13在OutputConfiguration类中添加了两个API,用于设置和获取当前OutputConfiguration的镜像值
public void setMirrorMode(int mirrorMode)
Description:
MIRROR_MODE_AUTO
, with which the camera API will mirror the output images horizontally for front facing cameraSurfaceTexture.getTransformMatrix(float[])
.public int getMirrorMode()
Description:
setMirrorMode(int)
is called first, this function returns MIRROR_MODE_AUTO
.当设置镜像模式为 MIRROR_MODE_NONE
,预览效果大致如下
当设置镜像模式为 MIRROR_MODE_H
,预览效果大致如下
当设置镜像模式为 MIRROR_MODE_V
,预览效果大致如下
原文链接:
https://android-camera.com/android-camera-api/android13-camera-new-feature/android13-camera-mirror-support-by-setmirrormode.html
~~END~~