Maksim Surov
Maksim Surov

Reputation: 613

Android camera, how to set the upper limit of exposure time?

My android application captures preview frames. It is necessary that the frames be not blurred. This requires to limit the exposure time of the sensor. For example, I want the exposure time be less than 10ms, and the white-balance adjuster uses ISO only.

The only solution I found is the fixing of SENSOR_EXPOSURE_TIME and SENSOR_SENSITIVITY:

public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
{
    // measure ISO and exposure
    mExposure = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
    mSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
    ...
}

void prepareCapturing()
{
    // setting the necessary values of ISO and exposure
    if (mExposure > 10.0 * 1e+6)
    {
        double exposure = 10.0 * 1e+6;
        double sens = mExposure * mSensitivity / exposure;

        mPreviewRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long)exposure);
        mPreviewRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, (int)sens);
    }

    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
    setRepeatingRequest();
}

I call the method prepareCapturing before running my algorithm of preview frame analyzing.

This approach works, but it requires to disable android.control.aeMode, thus the white balance will be off.

Also I tried to use standard scene modes like CONTROL_SCENE_MODE_ACTION, and CONTROL_SCENE_MODE_SPORTS, but exposure time anyway is about 40ms.

The question: is it possible using camera2 intereace to limit exposure time of the sensor, s.t. the white balance be active?

Upvotes: 1

Views: 4762

Answers (3)

Francisco Durdin Garcia
Francisco Durdin Garcia

Reputation: 13327

You can know the lower and upper values supported by your phone using the key SENSOR_INFO_EXPOSURE_TIME_RANGE

Check out the next method:

/**
 * Get exposure time range.
 *
 * @param cameraCharacteristics The properties of the camera.
 * @return Long exposure compensation range.
 * @see <a href="https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_EXPOSURE_TIME_RANGE">
 * CameraCharacteristics.SENSOR_INFO_EXPOSURE_TIME_RANGE</a>
 */
private static Range<Long> getExposureTimeRange(CameraCharacteristics cameraCharacteristics) {
    return cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_EXPOSURE_TIME_RANGE);
}

Upvotes: 0

Eddy Talvala
Eddy Talvala

Reputation: 18117

The primary API to require auto-exposure to remain below some maximum exposure time is the CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE control. For example, if you set that to (30,30), then the camera device may not use exposure times longer than 1/30th of a second.

The list of available ranges for a device is provided by CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES.

There's no direct control for setting max/min exposure values by themselves, and if no available target FPS range limits exposure times enough, your only other option is to use manual exposure control (if supported).

Whether that disables AWB is device-dependent, unfortunately - on some devices, the output of the auto-exposure routine is essential for the white balance algorithm to work.

Upvotes: 3

rsd_unleashed
rsd_unleashed

Reputation: 161

Check out Camera parameters' setExposureCompensation() method.

Here is the URL https://developer.android.com/reference/android/hardware/Camera.Parameters.html#setExposureCompensation(int)

enter image description here

Upvotes: -2

Related Questions