Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

java - Prevent flipping of the front facing camera

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

See https://github.com/hadders/camera-reverse

Specifically from MainActivity.java

mCamera.setDisplayOrientation(90);
Matrix matrix = new Matrix();
matrix.setScale(-1, 1);
matrix.postTranslate(width, 0);
mTextureView.setTransform(matrix);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...