List of usage examples for android.hardware.camera2 CaptureRequest SENSOR_EXPOSURE_TIME
Key SENSOR_EXPOSURE_TIME
To view the source code for android.hardware.camera2 CaptureRequest SENSOR_EXPOSURE_TIME.
Click Source Link
Duration each pixel is exposed to light.
If the sensor can't expose this exact duration, it will shorten the duration exposed to the nearest possible value (rather than expose longer).
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 a 2 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); } }
From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java
protected void initBurstCapture(Builder captureBuilder, CaptureCallback captureCallback) { List<CaptureRequest> captureList = new ArrayList<>(); for (int i = 0; i < parameterHandler.Burst.GetValue() + 1; i++) { int pos = mRequestCounter.getAndIncrement(); captureBuilder.setTag(pos);/*from ww w. jav a 2 s . c o m*/ captureBuilder.addTarget(mImageReader.getSurface()); setupBurstCaptureBuilder(captureBuilder, i); captureList.add(captureBuilder.build()); ImageHolder imageHolder = new ImageHolder(); resultQueue.put(pos, imageHolder); } if (cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) > 500000 * 1000) cameraHolder.CaptureSessionH.StopRepeatingCaptureSession(); changeCaptureState(CaptureStates.image_capture_start); cameraHolder.CaptureSessionH.StartCaptureBurst(captureList, captureCallback, mBackgroundHandler); }
From source file:com.example.android.hdrviewfinder.HdrViewfinderActivity.java
/** * Start running an HDR burst on a configured camera session */// w w w.ja va 2s . c om 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.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()}. *///ww w . j a v a 2s . c o m 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(); } }