Example usage for android.hardware.camera2 CameraDevice TEMPLATE_ZERO_SHUTTER_LAG

List of usage examples for android.hardware.camera2 CameraDevice TEMPLATE_ZERO_SHUTTER_LAG

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraDevice TEMPLATE_ZERO_SHUTTER_LAG.

Prototype

int TEMPLATE_ZERO_SHUTTER_LAG

To view the source code for android.hardware.camera2 CameraDevice TEMPLATE_ZERO_SHUTTER_LAG.

Click Source Link

Document

Create a request suitable for zero shutter lag still capture.

Usage

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

/**
 * Request a stream of images.//w  w w  .ja va 2  s .c o m
 *
 * @return true if successful, false if there was an error submitting the
 *         capture request.
 */
private boolean sendRepeatingCaptureRequest() {
    Timber.v("sendRepeatingCaptureRequest()");
    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);

        builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE);

        builder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
        builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);

        addRegionsToCaptureRequestBuilder(builder);

        captureSession.setRepeatingRequest(builder.build(), captureManager, cameraHandler);
        return true;
    } catch (CameraAccessException e) {
        if (ZSL_ENABLED) {
            Timber.w(e, "Could not execute zero-shutter-lag repeating request.");
        } else {
            Timber.w(e, "Could not execute preview request.");
        }
        return false;
    }
}

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

/**
 * Request a stream of images.//from ww  w .  j  a v  a 2  s . co  m
 *
 * @return true if successful, false if there was an error submitting the
 *         capture request.
 */
private boolean sendRepeatingCaptureRequest() {
    Log.v(TAG, "sendRepeatingCaptureRequest()");
    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);

        builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE);

        builder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
        builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);

        addRegionsToCaptureRequestBuilder(builder);

        mCaptureSession.setRepeatingRequest(builder.build(), mCaptureManager, mCameraHandler);
        return true;
    } catch (CameraAccessException e) {
        if (ZSL_ENABLED) {
            Log.v(TAG, "Could not execute zero-shutter-lag repeating request.", e);
        } else {
            Log.v(TAG, "Could not execute preview request.", e);
        }
        return false;
    }
}

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

private boolean sendAutoExposureTriggerRequest(Flash flashMode) {
    Timber.v("sendAutoExposureTriggerRequest()");
    try {/*from   w  w w.j  av  a  2 s  .  co  m*/
        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);

        builder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
                CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);

        addRegionsToCaptureRequestBuilder(builder);
        addFlashToCaptureRequestBuilder(builder, flashMode);

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

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

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

/**
 *//*  www  . ja  v  a 2  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./*  ww w  .  j  ava  2  s.  co  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

private boolean sendAutoExposureTriggerRequest(Flash flashMode) {
    Log.v(TAG, "sendAutoExposureTriggerRequest()");
    try {/*from   w  w  w. jav a  2  s  . co  m*/
        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);

        builder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
                CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);

        addRegionsToCaptureRequestBuilder(builder);
        addFlashToCaptureRequestBuilder(builder, flashMode);

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

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

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

/**
 *//*from  ww w  . j  av  a2s. c om*/
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   ww  w. java 2s. c  o  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;
    }
}