List of usage examples for android.hardware.camera2 CaptureRequest CONTROL_EFFECT_MODE
Key CONTROL_EFFECT_MODE
To view the source code for android.hardware.camera2 CaptureRequest CONTROL_EFFECT_MODE.
Click Source Link
A special color effect to apply.
When this mode is set, a color effect will be applied to images produced by the camera device.
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 ww w .j ava2 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.visualnavigate.CameraFragment.java
/** * Creates a new {@link CameraCaptureSession} for camera preview. *///w ww . j a v a2s . c o m private void createCameraPreviewSession() { try { SurfaceTexture texture = mTextureView.getSurfaceTexture(); assert texture != null; // We configure the size of default buffer to be the size of camera preview we want. texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); // This is the output Surface we need to start preview. Surface surface = new Surface(texture); // We set up a CaptureRequest.Builder with the output Surface. mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); mPreviewRequestBuilder.addTarget(surface); // Here, we create a CameraCaptureSession for camera preview. mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() { @Override public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) { // The camera is already closed if (null == mCameraDevice) { return; } // When the session is ready, we start displaying the preview. mCaptureSession = cameraCaptureSession; try { // Auto focus should be continuous for camera preview. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); // grayscale mPreviewRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_MONO); // Flash is automatically enabled when necessary. setAutoFlash(mPreviewRequestBuilder); // Finally, we start displaying the camera preview. mPreviewRequest = mPreviewRequestBuilder.build(); mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } } @Override public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) { showToast("Failed"); } }, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:edu.umich.eecs.lab11.camera.CameraFragment.java
/** * Creates a new {@link CameraCaptureSession} for camera preview. *//* w ww .java 2 s . c o m*/ private void createCameraPreviewSession() { try { SurfaceTexture texture = mTextureView.getSurfaceTexture(); assert texture != null; // We configure the size of default buffer to be the size of camera preview we want. texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); // This is the output Surface we need to start preview. Surface surface = new Surface(texture); // We set up a CaptureRequest.Builder with the output Surface. mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); mPreviewRequestBuilder.addTarget(surface); mPreviewRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_MONO); // Here, we create a CameraCaptureSession for camera preview. mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() { @Override public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) { // The camera is already closed if (null == mCameraDevice) { return; } // When the session is ready, we start displaying the preview. mCaptureSession = cameraCaptureSession; try { // Auto focus should be continuous for camera preview. mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); // Flash is automatically enabled when necessary. setAutoFlash(mPreviewRequestBuilder); // Finally, we start displaying the camera preview. mPreviewRequest = mPreviewRequestBuilder.build(); mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } } @Override public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) { showToast("Failed"); } }, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
From source file:net.ddns.mlsoftlaberge.trycorder.TryviscamFragment.java
private void setVisionMode(CaptureRequest.Builder builder) { String sayeffect = ""; // set effect for preview switch (mVisionEffect) { case 1:/*from ww w . j a v a 2 s. c o m*/ sayeffect = "View Normal"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_OFF); break; case 2: sayeffect = "View Mono"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_MONO); break; case 3: sayeffect = "View Negative"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_NEGATIVE); break; case 4: sayeffect = "View Blackboard"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_BLACKBOARD); break; case 5: sayeffect = "View Whiteboard"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_WHITEBOARD); break; case 6: sayeffect = "View Sepia"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_SEPIA); break; case 7: sayeffect = "View Solarize"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_SOLARIZE); break; case 8: sayeffect = "View Posterize"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_POSTERIZE); break; case 9: sayeffect = "View Aqua"; builder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureRequest.CONTROL_EFFECT_MODE_AQUA); break; } // set scene-mode for preview switch (mVisionScene) { case 1: saypost(sayeffect + ", Portrait"); builder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_PORTRAIT); break; case 2: saypost(sayeffect + ", Night Portrait"); builder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_NIGHT_PORTRAIT); break; } }