java - 使用camera2拍照时如何获得曝光时间?

标签 java android android-camera2

您好,我使用android相机2,我想获取我的照片在没有Exif接口(interface)的情况下保存时的曝光时间。

可以得到这个值吗?怎么办?

我尝试了很多次,但结果是0

这是我的代码:

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();
}

我将此代码放在 captureComplete 上,我认为这是获取此值的最佳位置。

谢谢!

最佳答案

您需要使用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();
}

关于java - 使用camera2拍照时如何获得曝光时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52278412/

相关文章:

java - 为什么 Android Studio 不自动导入正确的包 android.support.v4.app.Fragment

java - 在 Android 上对 UI 元素采用响应式(Reactive)编程有什么真正的好处吗?

android - Maven Eclipse 插件不会将 Android support-v4 添加到构建路径

android - 在 Android 上 - 如何从广角相机捕获图像/视频?

java - 以编程方式创建布局时在 Camera2 API 中预览拉伸(stretch)

java - 如何在jtable中添加系统命令结果?

java - 如何在 Java 中使用 HttpSession 跟踪登录尝试?

java - android.view.InflateException : Binary XML file line #24: Binary XML file line #17: Error inflating class android. support.v7.widget.SwipeRefreshLayout

android - Android 上的 Python 3 使用 TerminalIDE

java - Camera2 api 将相机切换为正常和黑白