防止前置摄像头翻转 [英] Prevent flipping of the front facing camera
问题描述
我试图访问Android的前置摄像头的原始feed。默认情况下,前置摄像头的预览被水平翻转,所以用户可以看到自己,就像看着一面镜子 - 这是伟大的,但不是我需要的。什么是最好的方式来获得原料?有没有方法禁用自动翻转,或者我应该尝试在代码自己翻转它?
I'm attempting to access the raw feed of android's front facing camera. By default, the front facing camera's preview is flipped horizontally so users can see themselves as if looking into a mirror - that's great, but not what I need. What's the best way to get the raw feed? Is there some way to disable the automatic flipping, or should I attempt to flip it in code myself? My application needs to display a real-time feed of the front facing camera without it being flipped like a mirror.
推荐答案
如果你的电脑没有镜像,我的应用程序需要显示前置摄像头的实时馈送。要使用前置摄像头进行条码扫描,您可以使用TextureView并对其应用变换矩阵。当纹理更新时,您可以读取图像数据并使用。
If you want to use a front-facing camera for barcode scanning you can use TextureView and apply a transformation matrix to it. When the texture is updated you can read the image data and use that.
请参阅 https://github.com/hadders/camera-reverse
特别来自MainActivity.java
Specifically from MainActivity.java
mCamera.setDisplayOrientation(90);
Matrix matrix = new Matrix();
matrix.setScale(-1, 1);
matrix.postTranslate(width, 0);
mTextureView.setTransform(matrix);
这篇关于防止前置摄像头翻转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!