1

我在我的 android 应用程序中使用 camera2 api 并想手动控制快门速度。这就是我设置快门速度的方式:

protected void setShutterSpeed(long exposureTime) {
    if (null == cameraDevice) {
        Log.e(TAG, "updatePreview error, return");
    }

    captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
    captureRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, 100);
    captureRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, exposureTime);

    try {
        cameraCaptureSessions.setRepeatingRequest(captureRequestBuilder.build(), null, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

这就是我创建 CaptureRequestBuilder 的方式:

captureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
captureRequestBuilder.addTarget(surface);
captureRequestBuilder.addTarget(imageReader.getSurface());

cameraDevice.createCaptureSession(Arrays.asList(surface, imageReader.getSurface()), new CameraCaptureSession.StateCallback() {
    @Override
    public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
        //The camera is already closed
        if (null == cameraDevice) {
             return;
        }
        // When the session is ready, we start displaying the preview.
        cameraCaptureSessions = cameraCaptureSession;
        updatePreview();
    }
    @Override
    public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
        Toast.makeText(AndroidCameraApi.this, "Configuration change", Toast.LENGTH_SHORT).show();
    }
}, null);

问题是当我设置快门速度时,它只设置 1 秒或 1 帧然后重置。但是当我不将 ImageReaders 表面添加到 CaptureRequestBuilder 目标输出时,它可能仅适用于 TexturePreview 表面。所以我认为问题出在 ImageReader 中。

有人知道这个问题的解决方案吗?

PS 其他设置(如 ISO 和曝光补偿)适用于两个表面。

4

0 回答 0