1

I am using camera2 api in my android app and want to manually control shutter-speed. This is how I set shutter-speed:

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

This is how I create 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);

The problem is that when I set shutter-speed, it sets ONLY for 1 second or 1 frame and then resets. But it may setts well only for TexturePreview surface when I do not add ImageReaders surface to CaptureRequestBuilder target outputs. So I assume that problem is in ImageReader.

Does anybody know solution for this problem?

P.S. other settings like ISO and Exposure compensation works well for both surfaces.

Vitalii Smal
  • 31
  • 1
  • 4

0 Answers0