Example usage for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE

List of usage examples for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE

Introduction

In this page you can find the example usage for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE.

Prototype

Key CONTROL_AE_MODE

To view the source code for android.hardware.camera2 CaptureRequest CONTROL_AE_MODE.

Click Source Link

Document

The desired mode for the camera device's auto-exposure routine.

This control is only effective if CaptureRequest#CONTROL_MODE android.control.mode is AUTO.

When set to any of the ON modes, the camera device's auto-exposure routine is enabled, overriding the application's selected exposure time, sensor sensitivity, and frame duration ( CaptureRequest#SENSOR_EXPOSURE_TIME android.sensor.exposureTime , CaptureRequest#SENSOR_SENSITIVITY android.sensor.sensitivity , and CaptureRequest#SENSOR_FRAME_DURATION android.sensor.frameDuration ).

Usage

From source file:fbla.hhs.eclat.Camera.Camera2BasicFragment.java

/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished./*from  w w w.  ja  v  a 2 s.  c o m*/
 */
private void unlockFocus(CameraCaptureSession capture) {
    try {
        // Reset the auto-focus trigger
        if (cameraType == 0) {
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                    CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
            //mCaptureSession=capture;
        } else {
            if (mCaptureSession == null) {
                mCaptureSession = capture;
            }
        }

        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        /*mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
            mBackgroundHandler);*/
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.mgtv.qxx.ttsdemo.Camera2BasicFragment.java

private void setAutoFlash(CaptureRequest.Builder requestBuilder) {
    if (mFlashSupported && mFlashAllowed) {
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
    } else {//from  w  w  w. j av  a2s  . co  m
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
    }
}

From source file:com.ape.camera2raw.Camera2RawFragment.java

/**
 * Configure the given {@link CaptureRequest.Builder} to use auto-focus, auto-exposure, and
 * auto-white-balance controls if available.
 * <p/>//w  w w. j  a  v  a  2  s . co  m
 * Call this only with {@link #mCameraStateLock} held.
 *
 * @param builder the builder to configure.
 */
private void setup3AControlsLocked(CaptureRequest.Builder builder) {
    // Enable auto-magical 3A run by camera device
    builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);

    Float minFocusDist = mCharacteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);

    // If MINIMUM_FOCUS_DISTANCE is 0, lens is fixed-focus and we need to skip the AF run.
    mNoAFRun = (minFocusDist == null || minFocusDist == 0);

    if (!mNoAFRun) {
        // If there is a "continuous picture" mode available, use it, otherwise default to AUTO.
        if (contains(mCharacteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES),
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)) {
            builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        } else {
            builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
        }
    }

    // If there is an auto-magical flash control mode available, use it, otherwise default to
    // the "on" mode, which is guaranteed to always be available.
    if (contains(mCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES),
            CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH)) {
        builder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
    } else {
        builder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
    }

    // If there is an auto-magical white balance control mode available, use it.
    if (contains(mCharacteristics.get(CameraCharacteristics.CONTROL_AWB_AVAILABLE_MODES),
            CaptureRequest.CONTROL_AWB_MODE_AUTO)) {
        // Allow AWB to run auto-magically if this device supports this
        builder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
    }
}

From source file:com.microsoft.projectoxford.face.samples.ui.Camera2BasicFragment.java

private void setAutoFlash(CaptureRequest.Builder requestBuilder) {
    if (mFlashSupported && flashon) {
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
    }//from   w w  w .j av  a 2 s  .  c  om
}