首页 > 解决方案 > how can i get EXPOSURE TIME when i take picture using camera2?

问题描述

Hello I use android camera 2 and I want to get the exposure time when my picture is saved without Exif interface.

It's possible to get this value ? How do that ?

I try many time but the result is 0

There is my code:

public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
    super.onCaptureCompleted(session, request, result);
    Toast.makeText(MainActivity.this, "Saved "+file, Toast.LENGTH_SHORT).show();

    Log.d(TAG, String.valueOf(result.get(CaptureRequest.SENSOR_EXPOSURE_TIME)));

    createCameraPreview();
}

I put this code on captureComplete I think it's the best place to get this value.

thanks!

标签: javaandroidandroid-camera2

解决方案


您需要使用CaptureResult而不是CaptureRequest. 您可以在下面的示例中看到如何:

public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
     super.onCaptureCompleted(session, request, result);
     Toast.makeText(MainActivity.this, "Saved "+file, Toast.LENGTH_SHORT).show();

     Log.d(TAG, String.valueOf(result.get(CaptureResult.SENSOR_EXPOSURE_TIME)));

     createCameraPreview();
}

推荐阅读