libgpuimage/src/main/java/org/wysaid/camera/Camera2Instance.java
private void captureStillPicture() {
        try {
            final Activity activity = mActivity;
            if (null == activity || null == mCameraDevice) {
                return;
            }
            // This is the CaptureRequest.Builder that we use to take a picture.
            final CaptureRequest.Builder captureBuilder =
                    mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
            captureBuilder.addTarget(mImageReader.getSurface());

            // Use the same AE and AF modes as the preview.
            captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
            setAutoFlash(captureBuilder);

            // Orientation
//            int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
//            captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(rotation));
//
//            Log.d(TAG, "_TEST2_ mSensorOrientation:" + mSensorOrientation);
//            Log.d(TAG, "_TEST2_ rotation:" + rotation);
//            Log.d(TAG, "_TEST2_ getOrientation:" + getOrientation(rotation));

            captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, (mRotation + mSensorOrientation) % 360);

            CameraCaptureSession.CaptureCallback CaptureCallback
                    = new CameraCaptureSession.CaptureCallback() {

                @Override
                public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                               @NonNull CaptureRequest request,
                                               @NonNull TotalCaptureResult result) {
//                    showToast("Saved: " + mFile);
//                    Toast.makeText(mActivity, "Saved: " + mFile, Toast.LENGTH_LONG).show();
//                    Log.d(TAG, mFile.toString());
                    unlockFocus();
                }
            };

            mCaptureSession.stopRepeating();
            mCaptureSession.abortCaptures();
            mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
        } catch (CameraAccessException e) {
            e.printStackTrace();
        }
    }
/**
     * Capture a still picture. This method should be called when we get a response in
     * {@link #mCaptureCallback} from both {@link #lockFocus()}.
     */
Capture a still picture. This method should be called when we get a response in
#mCaptureCallback from both  #lockFocus().
Capture a still picture . This method should be called when we get a response in #mCaptureCallback from both #lockFocus () .
private void captureStillPicture() {
        try {
            final Activity activity = mActivity;
            if (null == activity || null == mCameraDevice) {
                return;
            }
            final CaptureRequest.Builder captureBuilder =
                    mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
            captureBuilder.addTarget(mImageReader.getSurface());
            captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
            setAutoFlash(captureBuilder);
            Log.d(TAG, "_TEST2_ mSensorOrientation:" + mSensorOrientation);
            Log.d(TAG, "_TEST2_ rotation:" + rotation);
            Log.d(TAG, "_TEST2_ getOrientation:" + getOrientation(rotation));
            captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, (mRotation + mSensorOrientation) % 360);
            CameraCaptureSession.CaptureCallback CaptureCallback
                    = new CameraCaptureSession.CaptureCallback() {
                @Override
                public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                               @NonNull CaptureRequest request,
                                               @NonNull TotalCaptureResult result) {
                    showToast("Saved: " + mFile);
                    Toast.makeText(mActivity, "Saved: " + mFile, Toast.LENGTH_LONG).show();
                    Log.d(TAG, mFile.toString());
                    unlockFocus();
                }
            };
            mCaptureSession.stopRepeating();
            mCaptureSession.abortCaptures();
            mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
        } catch (CameraAccessException e) {
            e.printStackTrace();
        }
    }
private void captureStillPicture ( ) { try { final Activity activity = mActivity ; if ( null == activity || null == mCameraDevice ) { return ; } final CaptureRequest . Builder captureBuilder = mCameraDevice . createCaptureRequest ( CameraDevice . TEMPLATE_STILL_CAPTURE ) ; captureBuilder . addTarget ( mImageReader . getSurface ( ) ) ; captureBuilder . set ( CaptureRequest . CONTROL_AF_MODE , CaptureRequest . CONTROL_AF_MODE_CONTINUOUS_PICTURE ) ; setAutoFlash ( captureBuilder ) ; captureBuilder . set ( CaptureRequest . JPEG_ORIENTATION , ( mRotation + mSensorOrientation ) % 360 ) ; CameraCaptureSession . CaptureCallback CaptureCallback = new CameraCaptureSession . CaptureCallback ( ) { @ Override public void onCaptureCompleted ( @ NonNull CameraCaptureSession session , @ NonNull CaptureRequest request , @ NonNull TotalCaptureResult result ) { unlockFocus ( ) ; } } ; mCaptureSession . stopRepeating ( ) ; mCaptureSession . abortCaptures ( ) ; mCaptureSession . capture ( captureBuilder . build ( ) , CaptureCallback , null ) ; } catch ( CameraAccessException e ) { e . printStackTrace ( ) ; } }
Capture a still picture.
Capture a still picture .
// This is the CaptureRequest.Builder that we use to take a picture. // Use the same AE and AF modes as the preview. // Orientation //            int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); //            captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(rotation)); // //            Log.d(TAG, "_TEST2_ mSensorOrientation:" + mSensorOrientation); //            Log.d(TAG, "_TEST2_ rotation:" + rotation); //            Log.d(TAG, "_TEST2_ getOrientation:" + getOrientation(rotation)); //                    showToast("Saved: " + mFile); //                    Toast.makeText(mActivity, "Saved: " + mFile, Toast.LENGTH_LONG).show(); //                    Log.d(TAG, mFile.toString());