如何防止android从前置摄像头反转图像? [英] How to keep android from inverting the image from the front facing camera?

查看:36
本文介绍了如何防止android从前置摄像头反转图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的视频相机应用确实在横向模式下录制,但前置摄像头预览的是常规图像,但实际录制的内容是跨轴镜像(翻转或倒转).

My video Camera app does record in the landscape mode, but the front facing camera previews the regular image, but the actual recording is mirrored (flipped or inverted) across the axis.

在普通后置摄像头上一切正常.

Everything works great on normal rear camera.

有人可以建议我避免它吗?任何建议或源代码都会有很大帮助.谢谢你.

Can anybody suggest me a way to avoid it ? Any suggestions or source code would help a lot. Thank you.

推荐答案

坏消息:此镜像已硬编码到相机服务中,无法禁用.

The bad news: this mirroring is hardcoded into the camera service, and can not be disabled.

好消息:如果您使用的是最近的 API(API 级别 >= 14),您可以轻松使用 TextureView 将预览图像镜像回原始图像.参考 Android 文档中的 TextureView Example,然后使用 setTransform 设置镜像变换.这会将预览图像恢复为未镜像的原始图像.

The good news: if you are on a recent API (API level >= 14), you can easily use a TextureView to mirror the preview image back to the original. Take the TextureView Example over at the Android Documentation, then use setTransform to set a mirroring transform. This will revert the preview image back to the non-mirrored original.

请注意,镜像变换与在 X 轴上具有 -1 比例的缩放变换相同.

Note that a mirror transform is the same as a scaling transform with a -1 scale on the X axis.

如果您使用的是较旧的 API 版本,您也许可以对 SurfaceView 执行相同的操作(使用 setScaleX,API 级别 >= 11).

If you are on an older API version, you might be able to do the same with a SurfaceView (using setScaleX, API level >= 11).

这篇关于如何防止android从前置摄像头反转图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆