Example usage for android.hardware.camera2 CaptureRequest HOT_PIXEL_MODE

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

Introduction

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

Prototype

Key HOT_PIXEL_MODE

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

Click Source Link

Document

Operational mode for hot pixel correction.

Hotpixel correction interpolates out, or otherwise removes, pixels that do not accurately measure the incoming light (i.e.

Usage

From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java

/**
 * Capture a still picture. This method should be called when we get a response in
 *
 *//*from  w  w  w.j a  v  a2 s  .c  o  m*/
protected void captureStillPicture() {
    Log.d(TAG, "StartStillCapture");

    // Use the same AE and AF modes as the preview.
    try {
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, cameraHolder.get(CaptureRequest.CONTROL_AF_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, cameraHolder.get(CaptureRequest.CONTROL_AE_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.FLASH_MODE, cameraHolder.get(CaptureRequest.FLASH_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE,
                cameraHolder.get(CaptureRequest.COLOR_CORRECTION_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM,
                cameraHolder.get(CaptureRequest.COLOR_CORRECTION_TRANSFORM));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS,
                cameraHolder.get(CaptureRequest.COLOR_CORRECTION_GAINS));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.TONEMAP_CURVE, cameraHolder.get(CaptureRequest.TONEMAP_CURVE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        if (Build.VERSION.SDK_INT >= VERSION_CODES.M)
            captureBuilder.set(CaptureRequest.TONEMAP_GAMMA, cameraHolder.get(CaptureRequest.TONEMAP_GAMMA));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }

    try {
        int awb = cameraHolder.get(CaptureRequest.CONTROL_AWB_MODE);
        captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, awb);
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.EDGE_MODE, cameraHolder.get(CaptureRequest.EDGE_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.HOT_PIXEL_MODE, cameraHolder.get(CaptureRequest.HOT_PIXEL_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
                cameraHolder.get(CaptureRequest.NOISE_REDUCTION_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
                cameraHolder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        long val = 0;
        if (!parameterHandler.ManualIso.GetStringValue().equals(KEYS.AUTO))
            val = (long) (AbstractManualShutter.getMilliSecondStringFromShutterString(
                    parameterHandler.ManualShutter.getStringValues()[parameterHandler.ManualShutter.GetValue()])
                    * 1000f);
        else
            val = cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME);
        Log.d(TAG, "Set ExposureTime for Capture to:" + val);
        captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, val);
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY,
                cameraHolder.get(CaptureRequest.SENSOR_SENSITIVITY));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE,
                cameraHolder.get(CaptureRequest.CONTROL_EFFECT_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE,
                cameraHolder.get(CaptureRequest.CONTROL_SCENE_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE,
                cameraHolder.get(CaptureRequest.LENS_FOCUS_DISTANCE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION,
                cameraUiWrapper.getActivityInterface().getOrientation());
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE,
                cameraHolder.get(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        captureBuilder.set(CaptureRequest.SCALER_CROP_REGION,
                cameraHolder.get(CaptureRequest.SCALER_CROP_REGION));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    try {
        if (appSettingsManager.getApiString(AppSettingsManager.SETTING_LOCATION).equals(KEYS.ON))
            captureBuilder.set(CaptureRequest.JPEG_GPS_LOCATION,
                    cameraUiWrapper.getActivityInterface().getLocationHandler().getCurrentLocation());
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }

    prepareCaptureBuilder(captureBuilder);
    imagecount = 0;
    //mDngResult = null;
    if (parameterHandler.Burst != null && parameterHandler.Burst.GetValue() > 0) {
        initBurstCapture(captureBuilder, CaptureCallback);
    } else {
        //cameraHolder.CaptureSessionH.StopRepeatingCaptureSession();
        captureBuilder.setTag(mRequestCounter.getAndIncrement());
        captureBuilder.addTarget(mImageReader.getSurface());
        if (cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) != null
                && cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) > 500000 * 1000)
            cameraHolder.CaptureSessionH.StopRepeatingCaptureSession();
        ImageHolder imageHolder = new ImageHolder();
        resultQueue.put((int) captureBuilder.build().getTag(), imageHolder);
        changeCaptureState(CaptureStates.image_capture_start);
        cameraHolder.CaptureSessionH.StartImageCapture(captureBuilder, CaptureCallback, mBackgroundHandler);
    }
}