How to get current Exposure for Camera2 API in and

2019-06-27 17:44发布

问题:

In android.hardware.Camera old, I use code below get current Exposure and get it for Camera

Camera.Parameters param = mCamera.getParameters();
currentExposure += param.getExposureCompensationStep();
param.setExposureCompensation((int) currentExposure);
Timber.d("exposure:" + currentExposure);
mCamera.setParameters(param);

How to use it for Camera2 API new. Please. Help me!

回答1:

  1. There must be a call captureSession.setRepeatingRequest(request, captureCallback, ...); in your code.
  2. CaptureResult instance is passed to this captureCallback.
  3. You can continuously get exposure (in nanoseconds) from CaptureResult via key CaptureResult.SENSOR_EXPOSURE_TIME.


回答2:

Try this for Camera Characteristics.

mCameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);



回答3:

Try this

Range<Long> range = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_EXPOSURE_TIME_RANGE);


回答4:

In camera 2 api you have to define camera manger

private android.hardware.camera2.CameraManager manager;

//better to add inside constructor
manager = (android.hardware.camera2.CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);

Next steps You can get camera characteristics like this

    for (String cameraId : manager.getCameraIdList()) {
         CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);

         //get camera mode
         Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);

         //getting Stream configuration 
         StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
        }