我在我的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中。
有人知道这个问题的解决方案吗?
P.S。 ISO和曝光补偿等其他设置适用于两个表面。