Front Camera in Camera2 not capturing image

前端 未结 5 915
一向
一向 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:48

    In lockFocus() method, replace line

    mCaptureSession.capture(mPreviewRequestBuilder.build(),
                                                  mCaptureCallback,    mBackgroundHandler);
    

    with

    captureStillPicture();
    

    And to prevent Unwanted orientation you can use

    /** * Conversion from screen rotation to JPEG orientation. */

       static {
           ORIENTATIONS.append(Surface.ROTATION_0, 270);
           ORIENTATIONS.append(Surface.ROTATION_90, 0);
           ORIENTATIONS.append(Surface.ROTATION_180, 180);
           ORIENTATIONS.append(Surface.ROTATION_270, 270);
       }
    

提交回复
热议问题