Example usage for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE

List of usage examples for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE

Introduction

In this page you can find the example usage for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE.

Prototype

Key CONTROL_AE_MODE

To view the source code for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE.

Click Source Link

Document

The desired mode for the camera device's auto-exposure routine.

This control is only effective if CaptureRequest#CONTROL_MODE android.control.mode is AUTO.

When set to any of the ON modes, the camera device's auto-exposure routine is enabled, overriding the application's selected exposure time, sensor sensitivity, and frame duration ( CaptureRequest#SENSOR_EXPOSURE_TIME android.sensor.exposureTime , CaptureRequest#SENSOR_SENSITIVITY android.sensor.sensitivity , and CaptureRequest#SENSOR_FRAME_DURATION android.sensor.frameDuration ).

Usage

From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java

/**
 * Capture a still picture. This method should be called when we get a response in
 *
 *///from  w  ww .j  a v a  2 s  . c  o  m
protected void captureStillPicture() {
    Log.d(TAG, "StartStillCapture");

    // Use the same AE and AF modes as the preview.
    try {
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, cameraHolder.get(CaptureRequest.CONTROL_AF_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, cameraHolder.get(CaptureRequest.CONTROL_AE_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.FLASH_MODE, cameraHolder.get(CaptureRequest.FLASH_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE,
                cameraHolder.get(CaptureRequest.COLOR_CORRECTION_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM,
                cameraHolder.get(CaptureRequest.COLOR_CORRECTION_TRANSFORM));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS,
                cameraHolder.get(CaptureRequest.COLOR_CORRECTION_GAINS));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.TONEMAP_CURVE, cameraHolder.get(CaptureRequest.TONEMAP_CURVE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        if (Build.VERSION.SDK_INT >= VERSION_CODES.M)
            captureBuilder.set(CaptureRequest.TONEMAP_GAMMA, cameraHolder.get(CaptureRequest.TONEMAP_GAMMA));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }

    try {
        int awb = cameraHolder.get(CaptureRequest.CONTROL_AWB_MODE);
        captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, awb);
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.EDGE_MODE, cameraHolder.get(CaptureRequest.EDGE_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.HOT_PIXEL_MODE, cameraHolder.get(CaptureRequest.HOT_PIXEL_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
                cameraHolder.get(CaptureRequest.NOISE_REDUCTION_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
                cameraHolder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        long val = 0;
        if (!parameterHandler.ManualIso.GetStringValue().equals(KEYS.AUTO))
            val = (long) (AbstractManualShutter.getMilliSecondStringFromShutterString(
                    parameterHandler.ManualShutter.getStringValues()[parameterHandler.ManualShutter.GetValue()])
                    * 1000f);
        else
            val = cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
        Log.d(TAG, "Set ExposureTime for Capture to:" + val);
        captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, val);
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY,
                cameraHolder.get(CaptureRequest.SENSOR_SENSITIVITY));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE,
                cameraHolder.get(CaptureRequest.CONTROL_EFFECT_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE,
                cameraHolder.get(CaptureRequest.CONTROL_SCENE_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE,
                cameraHolder.get(CaptureRequest.LENS_FOCUS_DISTANCE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION,
                cameraUiWrapper.getActivityInterface().getOrientation());
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE,
                cameraHolder.get(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.SCALER_CROP_REGION,
                cameraHolder.get(CaptureRequest.SCALER_CROP_REGION));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        if (appSettingsManager.getApiString(AppSettingsManager.SETTING_LOCATION).equals(KEYS.ON))
            captureBuilder.set(CaptureRequest.JPEG_GPS_LOCATION,
                    cameraUiWrapper.getActivityInterface().getLocationHandler().getCurrentLocation());
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }

    prepareCaptureBuilder(captureBuilder);
    imagecount = 0;
    //mDngResult = null;
    if (parameterHandler.Burst != null && parameterHandler.Burst.GetValue() > 0) {
        initBurstCapture(captureBuilder, CaptureCallback);
    } else {
        //cameraHolder.CaptureSessionH.StopRepeatingCaptureSession();
        captureBuilder.setTag(mRequestCounter.getAndIncrement());
        captureBuilder.addTarget(mImageReader.getSurface());
        if (cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) != null
                && cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) > 500000 * 1000)
            cameraHolder.CaptureSessionH.StopRepeatingCaptureSession();
        ImageHolder imageHolder = new ImageHolder();
        resultQueue.put((int) captureBuilder.build().getTag(), imageHolder);
        changeCaptureState(CaptureStates.image_capture_start);
        cameraHolder.CaptureSessionH.StartImageCapture(captureBuilder, CaptureCallback, mBackgroundHandler);
    }
}

From source file:com.example.camera2apidemo.Camera2Fragment.java

private void startPrieview() {
    try {//from w w  w.j  av  a2  s. c  o  m
        mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mPreviewRequestBuilder.addTarget(surface);

        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        mPreviewRequest = mPreviewRequestBuilder.build();

        mCaptureSession.setRepeatingRequest(mPreviewRequest, null, null);

    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.example.camera2apidemo.Camera2Fragment.java

private void captureStillPicture() {
    try {//w  w w  . ja  v  a2 s  .c o  m

        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);
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

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

            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                    @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.example.camera2apidemo.Camera2Fragment.java

private void unlockFocus() {
    try {/*from  ww  w.jav a 2s .  co  m*/
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);

        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

        mCaptureSession.capture(mPreviewRequestBuilder.build(), null, mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest, null, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.example.testcamera.Camera2BasicFragmentGoogle.java

/**
 * Creates a new {@link CameraCaptureSession} for camera preview.
 *//*from ww  w . j a va  2s  .co m*/
private void createCameraPreviewSession() {
    try {
        SurfaceTexture texture = mTextureView.getSurfaceTexture();
        assert texture != null;

        // We configure the size of default buffer to be the size of camera preview we want.
        texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());

        // This is the output Surface we need to start preview.
        Surface surface = new Surface(texture);

        // We set up a CaptureRequest.Builder with the output Surface.
        mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mPreviewRequestBuilder.addTarget(surface);

        // Here, we create a CameraCaptureSession for camera preview.
        mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
                new CameraCaptureSession.StateCallback() {

                    @Override
                    public void onConfigured(CameraCaptureSession cameraCaptureSession) {
                        // The camera is already closed
                        if (null == mCameraDevice) {
                            return;
                        }

                        // When the session is ready, we start displaying the preview.
                        mCaptureSession = cameraCaptureSession;
                        try {
                            // Auto focus should be continuous for camera preview.
                            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                            // Flash is automatically enabled when necessary.
                            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                                    CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

                            // Finally, we start displaying the camera preview.
                            mPreviewRequest = mPreviewRequestBuilder.build();
                            mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
                                    mBackgroundHandler);
                        } catch (CameraAccessException e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
                        Activity activity = getActivity();
                        if (null != activity) {
                            Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show();
                        }
                    }
                }, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.tzutalin.dlibtest.CameraConnectionFragment.java

/**
 * Creates a new {@link CameraCaptureSession} for camera preview.
 *///from  w w w .  j  a  v a2s  .co  m
@SuppressLint("LongLogTag")
@DebugLog
private void createCameraPreviewSession() {
    try {
        final SurfaceTexture texture = textureView.getSurfaceTexture();
        assert texture != null;

        // We configure the size of default buffer to be the size of camera preview we want.
        texture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
        //texture.setOnFrameAvailableListener();

        // This is the output Surface we need to start preview.
        final Surface surface = new Surface(texture);

        // We set up a CaptureRequest.Builder with the output Surface.
        previewRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        //previewRequestBuilder.addTarget(surface);

        // Create the reader for the preview frames.
        previewReader = ImageReader.newInstance(previewSize.getWidth(), previewSize.getHeight(),
                ImageFormat.YUV_420_888, 2);

        previewReader.setOnImageAvailableListener(mOnGetPreviewListener, backgroundHandler);
        previewRequestBuilder.addTarget(previewReader.getSurface());

        // Here, we create a CameraCaptureSession for camera preview.
        cameraDevice.createCaptureSession(Arrays.asList(previewReader.getSurface()),
                new CameraCaptureSession.StateCallback() {

                    @Override
                    public void onConfigured(final CameraCaptureSession cameraCaptureSession) {
                        // The camera is already closed
                        if (null == cameraDevice) {
                            return;
                        }

                        // When the session is ready, we start displaying the preview.
                        captureSession = cameraCaptureSession;
                        try {
                            // Auto focus should be continuous for camera preview.
                            previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                            // Flash is automatically enabled when necessary.
                            previewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                                    CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

                            // Finally, we start displaying the camera preview.
                            previewRequest = previewRequestBuilder.build();
                            captureSession.setRepeatingRequest(previewRequest, captureCallback,
                                    backgroundHandler);
                        } catch (final CameraAccessException e) {
                            Timber.tag(TAG).e("Exception!", e);
                        }
                    }

                    @Override
                    public void onConfigureFailed(final CameraCaptureSession cameraCaptureSession) {
                        showToast("Failed");
                    }
                }, null);
    } catch (final CameraAccessException e) {
        Timber.tag(TAG).e("Exception!", e);
    }

    mOnGetPreviewListener.initialize(getActivity().getApplicationContext(), getActivity().getAssets(),
            mScoreView, inferenceHandler);
}

From source file:com.microblink.barcode.customcamera.camera2.Camera2Fragment.java

/**
 * Creates a new {@link CameraCaptureSession} for camera preview.
 *//* w ww  .j  a v  a 2 s . c om*/
private void createCameraPreviewSession() {
    try {
        SurfaceTexture texture = mTextureView.getSurfaceTexture();
        assert texture != null;

        // We configure the size of default buffer to be the size of camera preview we want.
        texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());

        // This is the output Surface we need to start preview.
        Surface surface = new Surface(texture);

        // We set up a CaptureRequest.Builder with the output Surface.
        mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mPreviewRequestBuilder.addTarget(surface);

        // Here, we create a CameraCaptureSession for camera preview.
        mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
                new CameraCaptureSession.StateCallback() {

                    @Override
                    public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
                        // The camera is already closed
                        if (null == mCameraDevice) {
                            return;
                        }

                        // When the session is ready, we start displaying the preview.
                        mCaptureSession = cameraCaptureSession;
                        try {
                            // Auto focus should be continuous for camera preview.
                            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                                    CaptureRequest.CONTROL_AE_MODE_ON);

                            // Finally, we start displaying the camera preview.
                            mPreviewRequest = mPreviewRequestBuilder.build();
                            mCaptureSession.setRepeatingRequest(mPreviewRequest, null, mBackgroundHandler);

                            // also prepare capture request for ImageReader
                            mPreviewRequestBuilder.addTarget(mImageReader.getSurface());
                            mFrameRequest = mPreviewRequestBuilder.build();
                            mPreviewRequestBuilder.removeTarget(mImageReader.getSurface());

                            // request frame to image reader
                            mCaptureSession.capture(mFrameRequest, null, mBackgroundHandler);

                        } catch (CameraAccessException e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
                        showToast("Failed");
                    }
                }, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:cliq.com.cliqgram.fragments.CameraFragment.java

/**
 * Creates a new {@link CameraCaptureSession} for camera preview.
 *///from   w  w  w  .  j a  va 2  s.c o  m
private void createCameraPreviewSession() {
    try {
        SurfaceTexture texture = mTextureView.getSurfaceTexture();
        assert texture != null;

        // We configure the size of default buffer to be the size of camera preview we want.
        texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());

        // This is the output Surface we need to start preview.
        Surface surface = new Surface(texture);

        // We set up a CaptureRequest.Builder with the output Surface.
        mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mPreviewRequestBuilder.addTarget(surface);

        // Here, we create a CameraCaptureSession for camera preview.
        mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
                new CameraCaptureSession.StateCallback() {

                    @Override
                    public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
                        // The camera is already closed
                        if (null == mCameraDevice) {
                            return;
                        }

                        // When the session is ready, we start displaying the preview.
                        mCaptureSession = cameraCaptureSession;
                        try {
                            // Auto focus should be continuous for camera preview.
                            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                            // Flash is automatically enabled when necessary.
                            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                                    CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

                            // Finally, we start displaying the camera preview.
                            mPreviewRequest = mPreviewRequestBuilder.build();
                            mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
                                    mBackgroundHandler);
                        } catch (CameraAccessException e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
                        showToast("Failed");
                    }
                }, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.example.android.hdrviewfinder.HdrViewfinderActivity.java

/**
 * Callbacks for CameraOps//from   www .j av a2 s  .  com
 */
@Override
public void onCameraReady() {
    // Ready to send requests in, so set them up
    try {
        CaptureRequest.Builder previewBuilder = mCameraOps.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        previewBuilder.addTarget(mProcessingNormalSurface);
        previewBuilder.setTag(mAutoExposureTag);
        mPreviewRequest = previewBuilder.build();

        mHdrBuilder = mCameraOps.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        mHdrBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
        mHdrBuilder.addTarget(mProcessingHdrSurface);

        switchRenderMode(0);

    } catch (CameraAccessException e) {
        String errorMessage = getErrorString(e);
        showErrorDialog(errorMessage);
    }
}

From source file:com.example.testcamera.Camera2BasicFragmentGoogle.java

/**
 * Capture a still picture. This method should be called when we get a response in
 * {@link #mCaptureCallback} from both {@link #lockFocus()}.
 *///  w  ww. j  av a  2s  . co m
private void captureStillPicture() {
    try {
        final Activity activity = getActivity();
        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);
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

        // Orientation
        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));

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

            @Override
            public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
                    TotalCaptureResult result) {
                Toast.makeText(getActivity(), "Saved: " + mFile, Toast.LENGTH_SHORT).show();
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}