How to get current exposure for Camera2 API in android

In android.hardware.Cameraold, I use the code below, get the current exposure and get it for the 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 the new API . You are welcome. Help me!

+4
source share
4 answers

Try this for camera specifications.

mCameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);

0
source
  1. There should be a call captureSession.setRepeatingRequest(request, captureCallback,...);in your code.
  2. CaptureResulttransmitted to this captureCallback.
  3. You can continuously receive exposure (in nanoseconds) from CaptureResultvia key CaptureResult.SENSOR_EXPOSURE_TIME.
0
source

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

In camera 2 api you need to identify the camera lizard

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 features like

    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);
        }
-1
source

Source: https://habr.com/ru/post/1677462/


All Articles