Example usage for android.hardware.camera2 CameraCharacteristics CONTROL_AWB_AVAILABLE_MODES

List of usage examples for android.hardware.camera2 CameraCharacteristics CONTROL_AWB_AVAILABLE_MODES

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraCharacteristics CONTROL_AWB_AVAILABLE_MODES.

Prototype

Key CONTROL_AWB_AVAILABLE_MODES

To view the source code for android.hardware.camera2 CameraCharacteristics CONTROL_AWB_AVAILABLE_MODES.

Click Source Link

Document

List of auto-white-balance modes for CaptureRequest#CONTROL_AWB_MODE android.control.awbMode that are supported by this camera device.

Not all the auto-white-balance modes may be supported by a given camera device.

Usage

From source file:com.example.aschere.cdhprototype2.Camera2RawFragment.java

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 {//from   w  w  w  . jav a2  s  . c o m
            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.ape.camera2raw.Camera2RawFragment.java

/**
 * Configure the given {@link CaptureRequest.Builder} to use auto-focus, auto-exposure, and
 * auto-white-balance controls if available.
 * <p/>//  www  . ja v  a 2s.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);
    }
}