如何让机器人从前置摄像头反转的形象呢? [英] How to keep android from inverting the image from the front facing camera?

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

问题描述

我的摄像头应用程序不会记录在风景模式,但面对镜头$ P $前pviews常规形象,但在实际拍摄的镜像(翻转或反转)跨轴。

一切的伟大工程,在正常的后置摄像头。

任何人都可以给我建议的方式来避免呢?任何建议或源$ C ​​$ C将有很大的帮助。谢谢。

解决方案

坏消息:这个镜像是很难codeD插入相机的服务,并且不能被禁用。

好消息:如果你是在最近的一个API(空气污染指数> = 14),你可以很容易地使用TextureView镜像preVIEW镜像恢复到原来的。就拿 TextureView 的例子在上Android的文档,然后使用<一个href="http://developer.android.com/reference/android/view/TextureView.html#setTransform%28android.graphics.Matrix%29">setTransform设置镜像变换。这将恢复preVIEW镜像恢复到非镜像原件。

请注意,一个反射镜变换的相同的缩放变换与-1尺度上的X轴。

如果你是一个较旧的API版本,你也许可以用一个SurfaceView做同样的(使用<一个href="http://developer.android.com/reference/android/view/View.html#setScaleX%28float%29">setScaleX, API级别> = 11)。

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.

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.

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

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

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

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