Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 454
daedalus28 Avatar asked Mar 17 '12 22:03

daedalus28


1 Answers

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);
like image 178
Steve Avatar answered Sep 18 '22 04:09

Steve