前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Android13 Camera New Feature--Mirror support

Android13 Camera New Feature--Mirror support

作者头像
雪月清
发布2022-09-21 14:54:43
7160
发布2022-09-21 14:54:43
举报
文章被收录于专栏:雪月清的随笔雪月清的随笔

Starting from Android 13, Android supports setting Mirror for each Camera Output Stream. This article introduces the specific usage method.

从Android13开始,Android支持为每个摄像头输出流设置镜像。本文介绍了具体的使用方法

OutputConfiguration Added APIs for Mirror

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的镜像值

setMirrorMode(设置镜像模式)

代码语言:javascript
复制
public void setMirrorMode(int mirrorMode)

Description:

  • If this functioin is not called, the mirroring mode for this output is MIRROR_MODE_AUTO, with which the camera API will mirror the output images horizontally for front facing camera
  • 如果该函数未调用,默认为自动镜像模式,前置摄像头将应用水平镜像效果
  • For efficiency, the mirror effect is applied as a transform flag, so it is only effective in some outputs. It works automatically for SurfaceView and TextureView outputs.
  • 为了提高效率,镜像效果作为变换flag被应用,因此它仅在某些输出中有效。它自动用于SurfaceView和TextureView输出
    • For manual use of SurfaceTexture, it is reflected in the value of SurfaceTexture.getTransformMatrix(float[]).
    • 对于使用SurfaceTexture的情况,它反映在getTransformMatrix中
    • For other end points, such as ImageReader, MediaRecorder, or MediaCodec, the mirror mode has no effect. If mirroring is needed for such outputs, the application needs to mirror the image buffers itself before passing them onward.
    • 对于ImageReader,MediaRecorder或MediaCodec来说,镜像模式不会生效。如果需要对这些输出做镜像,需要自己对原始buffer做处理

getMirrorMode(获取镜像模式)

代码语言:javascript
复制
public int getMirrorMode()

Description:

  • Get the current mirroring mode,If no setMirrorMode(int) is called first, this function returns MIRROR_MODE_AUTO.
  • 获取当前镜像模式,如果没有调用过设置镜像模式的接口,该方法将返回自动镜像模式

setMirrorMode Examples

MIRROR_MODE_NONE

当设置镜像模式为 MIRROR_MODE_NONE ,预览效果大致如下

MIRROR_MODE_H

当设置镜像模式为 MIRROR_MODE_H,预览效果大致如下

MIRROR_MODE_V

当设置镜像模式为 MIRROR_MODE_V,预览效果大致如下

原文链接:

https://android-camera.com/android-camera-api/android13-camera-new-feature/android13-camera-mirror-support-by-setmirrormode.html

~~END~~

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-08-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 雪月清的随笔 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • OutputConfiguration Added APIs for Mirror
    • setMirrorMode(设置镜像模式)
      • getMirrorMode(获取镜像模式)
      • setMirrorMode Examples
        • MIRROR_MODE_NONE
          • MIRROR_MODE_H
            • MIRROR_MODE_V
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档