Example usage for android.hardware.camera2 CameraMetadata CONTROL_AF_MODE_AUTO

List of usage examples for android.hardware.camera2 CameraMetadata CONTROL_AF_MODE_AUTO

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraMetadata CONTROL_AF_MODE_AUTO.

Prototype

int CONTROL_AF_MODE_AUTO

To view the source code for android.hardware.camera2 CameraMetadata CONTROL_AF_MODE_AUTO.

Click Source Link

Document

Basic automatic focus mode.

In this mode, the lens does not move unless the autofocus trigger action is called.

Usage

From source file:com.obviousengine.android.focus.ZslFocusCamera.java

/**
 *///from ww  w. jav a2 s.c o m
private boolean sendAutoFocusTriggerRequest() {
    Timber.v("sendAutoFocusTriggerRequest()");
    try {
        CaptureRequest.Builder builder;
        if (ZSL_ENABLED) {
            builder = device.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG);
        } else {
            builder = device.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        }

        builder.addTarget(previewSurface);

        if (ZSL_ENABLED) {
            builder.addTarget(captureImageReader.getSurface());
        }

        builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);

        addRegionsToCaptureRequestBuilder(builder);

        builder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);

        captureSession.capture(builder.build(), captureManager, cameraHandler);

        return true;
    } catch (CameraAccessException e) {
        Timber.w(e, "Could not execute auto focus trigger request.");
        return false;
    }
}

From source file:com.obviousengine.android.focus.ZslFocusCamera.java

/**
 * Like {@link #sendRepeatingCaptureRequest()}, but with the focus held
 * constant./*  w  ww .  ja v a2  s. c  o m*/
 *
 * @return true if successful, false if there was an error submitting the
 *         capture request.
 */
private boolean sendAutoFocusHoldRequest() {
    Timber.v("sendAutoFocusHoldRequest()");
    try {
        CaptureRequest.Builder builder;
        if (ZSL_ENABLED) {
            builder = device.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG);
        } else {
            builder = device.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        }

        builder.addTarget(previewSurface);

        if (ZSL_ENABLED) {
            builder.addTarget(captureImageReader.getSurface());
        }

        builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);

        builder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE);

        addRegionsToCaptureRequestBuilder(builder);
        // TODO: This should fire the torch, if appropriate.

        captureSession.setRepeatingRequest(builder.build(), captureManager, cameraHandler);

        return true;
    } catch (CameraAccessException e) {
        Timber.w(e, "Could not execute auto focus hold request.");
        return false;
    }
}

From source file:com.android.camera.one.v2.OneCameraZslImpl.java

/**
 *///  w  w w .  j a v  a2  s  . c o m
private boolean sendAutoFocusTriggerRequest() {
    Log.v(TAG, "sendAutoFocusTriggerRequest()");
    try {
        CaptureRequest.Builder builder;
        if (ZSL_ENABLED) {
            builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG);
        } else {
            builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        }

        builder.addTarget(mPreviewSurface);

        if (ZSL_ENABLED) {
            builder.addTarget(mCaptureImageReader.getSurface());
        }

        builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);

        addRegionsToCaptureRequestBuilder(builder);

        builder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);

        mCaptureSession.capture(builder.build(), mCaptureManager, mCameraHandler);

        return true;
    } catch (CameraAccessException e) {
        Log.v(TAG, "Could not execute auto focus trigger request.", e);
        return false;
    }
}

From source file:com.android.camera.one.v2.OneCameraZslImpl.java

/**
 * Like {@link #sendRepeatingCaptureRequest()}, but with the focus held
 * constant.//from w ww.ja  v a2s.co m
 *
 * @return true if successful, false if there was an error submitting the
 *         capture request.
 */
private boolean sendAutoFocusHoldRequest() {
    Log.v(TAG, "sendAutoFocusHoldRequest()");
    try {
        CaptureRequest.Builder builder;
        if (ZSL_ENABLED) {
            builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG);
        } else {
            builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        }

        builder.addTarget(mPreviewSurface);

        if (ZSL_ENABLED) {
            builder.addTarget(mCaptureImageReader.getSurface());
        }

        builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);

        builder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE);

        addRegionsToCaptureRequestBuilder(builder);
        // TODO: This should fire the torch, if appropriate.

        mCaptureSession.setRepeatingRequest(builder.build(), mCaptureManager, mCameraHandler);

        return true;
    } catch (CameraAccessException e) {
        Log.v(TAG, "Could not execute auto focus hold request.", e);
        return false;
    }
}