Example usage for android.hardware.camera2 CameraMetadata CONTROL_AF_TRIGGER_CANCEL

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

Introduction

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

Prototype

int CONTROL_AF_TRIGGER_CANCEL

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

Click Source Link

Document

Autofocus will return to its initial state, and cancel any currently active trigger.

Usage

From source file:com.example.joshf.conc.CameraFragment.java

/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished./*w  w  w  .  ja v  a2s .  c o  m*/
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        setAutoFlash(mPreviewRequestBuilder);
        Log.e("camera", " capture request");
        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.microsoft.projectoxford.face.samples.ui.Camera2BasicFragment.java

/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.//from ww w .jav  a  2  s.  co m
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        setAutoFlash(mPreviewRequestBuilder);
        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);
        if (!flashon) {
            flashon = true;
            lockFocus();
        } else {
            flashon = false;
            detectAndFrame();
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

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.  j  ava 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.vest.album.fragment.CameraBasicFragment.java

/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.// w w  w .ja v a 2s . c  o  m
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        setAutoFlash(mPreviewRequestBuilder);
        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) {
        callback.onPhotoError("?");
        e.printStackTrace();
    }
}

From source file:com.example.android.littleblack.CameraFragment.java

/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.// w w  w . jav a 2 s.  co  m
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        // Eric JU setAutoFlash(mPreviewRequestBuilder);
        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.example.camera2apidemo.Camera2BasicFragment.java

/**?
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished./*from  www.j a  va  2 s.  c  o  m*/
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger  // AF
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        // (???????, ?)
        setAutoFlash(mPreviewRequestBuilder);
        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.ape.camera2raw.Camera2RawFragment.java

/**
 * Called after a RAW/JPEG capture has completed; resets the AF trigger state for the
 * pre-capture sequence./*  ww  w .j  a v a  2s. c  o  m*/
 * <p/>
 * Call this only with {@link #mCameraStateLock} held.
 */
private void finishedCaptureLocked() {
    try {
        // Reset the auto-focus trigger in case AF didn't run quickly enough.
        if (!mNoAFRun) {
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);

            mCaptureSession.capture(mPreviewRequestBuilder.build(), mPreCaptureCallback, mBackgroundHandler);

            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CameraMetadata.CONTROL_AF_TRIGGER_IDLE);
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}