Example usage for android.hardware.camera2 CaptureRequest SENSOR_SENSITIVITY

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

Introduction

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

Prototype

Key SENSOR_SENSITIVITY

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

Click Source Link

Document

The amount of gain applied to sensor data before processing.

The sensitivity is the standard ISO sensitivity value, as defined in ISO 12232:2006.

The sensitivity must be within CameraCharacteristics#SENSOR_INFO_SENSITIVITY_RANGE android.sensor.info.sensitivityRange , and if if it less than CameraCharacteristics#SENSOR_MAX_ANALOG_SENSITIVITY android.sensor.maxAnalogSensitivity , the camera device is guaranteed to use only analog amplification for applying the gain.

If the camera device cannot apply the exact sensitivity requested, it will reduce the gain to the nearest supported value.

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
 *
 *///  w w  w.  j a v  a2  s .  c  om
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);
    }
}

From source file:com.example.android.hdrviewfinder.HdrViewfinderActivity.java

/**
 * Start running an HDR burst on a configured camera session
 *///from  ww  w.  j a v a 2  s  .co  m
public void setHdrBurst() {

    mHdrBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, 1600);
    mHdrBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, ONE_SECOND / 30);

    mHdrBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, mEvenExposure);
    mHdrBuilder.setTag(mEvenExposureTag);
    mHdrRequests.set(0, mHdrBuilder.build());

    mHdrBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, mOddExposure);
    mHdrBuilder.setTag(mOddExposureTag);
    mHdrRequests.set(1, mHdrBuilder.build());

    mCameraOps.setRepeatingBurst(mHdrRequests, mCaptureCallback, mUiHandler);
}

From source file:com.example.android.camera2basic.Camera2BasicFragment.java

private void initPreviewBuilder() {
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_OFF);

    mPreviewRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, valueAF);
    mPreviewRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, valueAETime);
    mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, valueAE);
    mPreviewRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, valueISO);
}

From source file:com.example.android.camera2basic.Camera2BasicFragment.java

public void createCameraPreviewSession_ISO() {
    try {//from  w  ww.ja  v a2s  .c o  m
        mPreviewRequestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, isoValue);
        mPreviewRequest = mPreviewRequestBuilder.build();
        mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.vest.album.fragment.CameraBasicFragment.java

/**
 * Capture a still picture. This method should be called when we get a response in
 * {@link #mCaptureCallback} from both {@link #lockFocus()}.
 *///  w ww . j  a  v  a2  s  .  c om
private void captureStillPicture() {
    try {
        final Activity activity = getActivity();
        if (null == activity || null == mCameraDevice) {
            return;
        }
        // This is the CaptureRequest.Builder that we use to take a picture.
        final CaptureRequest.Builder captureBuilder = mCameraDevice
                .createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReader.getSurface());
        // Use the same AE and AF modes as the preview.
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        captureBuilder.set(CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE,
                CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE_ON);
        captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) ((214735991 - 13231) / 2));
        captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 0);
        captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, (10000 - 100) / 2);// ISO
        setAutoFlash(captureBuilder);

        // Orientation
        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(rotation));

        CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() {

            @Override
            public void onCaptureCompleted(@NonNull CameraCaptureSession session,
                    @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
                //                    showToast("Saved: " + mFile);
                //                    Log.d(TAG, mFile.toString());
                //                    unlockFocus();
                handler.sendEmptyMessage(1);
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);
    } catch (CameraAccessException e) {
        callback.onPhotoError("?");
        e.printStackTrace();
    }
}