Created
December 26, 2018 05:37
-
-
Save yudikarma/5e473b3c42787bdd7acde327b89c10a2 to your computer and use it in GitHub Desktop.
captureStillPicture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void captureStillPicture() { | |
| try { | |
| if (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()); | |
| //set brignest | |
| captureBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,(getRange())); | |
| //Zoom | |
| captureBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoom); | |
| /* //try set this to fix image capture not same with preview | |
| mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, | |
| mBackgroundHandler);*/ | |
| // Use the same AE and AF modes as the preview. | |
| captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, | |
| CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); | |
| setAutoFlash(captureBuilder); | |
| // Orientation | |
| int rotation = 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) { | |
| unlockFocus(); | |
| } | |
| }; | |
| mCaptureSession.stopRepeating(); | |
| mCaptureSession.abortCaptures(); | |
| mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); | |
| } catch (CameraAccessException e) { | |
| Log.w(TAG, e); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and this my Preview Session
private void createCameraPreviewSession() {
try {
SurfaceTexture texture = mTextureView.getSurfaceTexture();
assert texture != null;