Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can camera2 API tell me the difference between the current exposure and the ideal one?

We're building a camera app, and we want to use manual exposure. We don't want the exposure algorithm to set the ISO and exposure duration; instead we want it to tell us what the difference is between the manual exposure that we set and the correct exposure according to the algorithm. That way, we can take this into account in our calculations.

iOS has such an API exposureTargetOffset. Does Android camera2 have such an API?

like image 881
Kartick Vaddadi Avatar asked Nov 16 '22 07:11

Kartick Vaddadi


1 Answers

I don't think that the camera2 library has such an API. However, you can calculate the difference between your ISO and exposure values, and the algorithmic ones.

Follow the below steps:

  1. While setting the preview, you put your custom capture callback :
    this.previewCaptureSession.setRepeatingRequest(previewSession.build(),
              customCaptureCallback, this.cameraHandler);
  1. In the custom call back you can enquire the ISO and exposure values that the algorithm calculates by looking at the current preview
CameraCaptureSession.CaptureCallback customCaptureCallback = new CameraCaptureSession.CaptureCallback() {
  @Override
      public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                                     @NonNull CaptureRequest request,
                                     @NonNull TotalCaptureResult result) {
        super.onCaptureCompleted(session, request, result);

        //you can store the values of these two below variables however you want

        final Long exposureValue = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
        final Integer isoValue = result.get(CaptureResult.SENSOR_SENSITIVITY);
      }
}
  1. You got the current ISO and exposure, now you can just compare it with the user given ISO and exposure value
like image 163
shubham sharma Avatar answered May 16 '23 05:05

shubham sharma