Prevent flipping of the front facing camera

前端 未结 2 2055
夕颜
夕颜 2020-12-03 15:01

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

2条回答
  •  温柔的废话
    2020-12-03 15:53

    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);
    

提交回复
热议问题