Front Camera in Camera2 not capturing image

前端 未结 5 918
一向
一向 2021-02-04 12:18

I have the code for the Camera2 from https://github.com/googlesamples/android-Camera2Basic.

The problem i\'m facing is that when i turn to my Front Camera, i cannot capt

5条回答
  •  无人共我
    2021-02-04 12:28

    @ArvindSingh's solution is not the best one, because you would also disable the focus functionality for the back camera. A better solution would be to do a camera facing check inside the takePicture like that:

    private void takePicture() {
        if (CameraCharacteristics.LENS_FACING_FRONT == mSelectedFacing) {
            // front camera selected, so take a picture without focus
            captureStillPicture();
        } else {
            // back camera selected, trigger the focus before creating an image
            lockFocus();
        }
    }
    

    For this solution you only need to save the current used facing somewhere like here in mSelectedFacing

提交回复
热议问题