android.hardware.camera2.TotalCaptureResult Java Examples
The following examples show how to use
android.hardware.camera2.TotalCaptureResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Camera2BasicFragment.java From Android-Camera2-Front-with-Face-Detection with Apache License 2.0 | 6 votes |
/** * Capture a still picture. This method should be called when we get a response in * {@link #mCaptureCallback} from both {@link #lockFocus()}. */ 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); 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(); } }; mCaptureSession.stopRepeating(); mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #2
Source File: Camera2Source.java From Camera2Vision with Apache License 2.0 | 6 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { if(request.getTag() == ("FOCUS_TAG")) { //The focus trigger is complete! //Resume repeating request, clear AF trigger. mAutoFocusCallback.onAutoFocus(true); mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, null); mPreviewRequestBuilder.setTag(""); mPreviewRequest = mPreviewRequestBuilder.build(); try { mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch(CameraAccessException ex) { Log.d(TAG, "AUTO FOCUS FAILURE: "+ex); } } else { process(result); } }
Example #3
Source File: OBCameraManager.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
private void updatePreview(final OBVideoPlayer videoPlayer) { if (null == cameraDevice) { return; } try { setUpCaptureRequestBuilder(previewBuilder); captureSession.setRepeatingRequest(previewBuilder.build(), new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { videoPlayer.invalidate(); super.onCaptureCompleted(session, request, result); } } , backgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #4
Source File: Camera2Source.java From Machine-Learning-Projects-for-Mobile-Applications with MIT License | 6 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { if (request.getTag() == ("FOCUS_TAG")) { //The focus trigger is complete! //Resume repeating request, clear AF trigger. mAutoFocusCallback.onAutoFocus(true); mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, null); mPreviewRequestBuilder.setTag(""); mPreviewRequest = mPreviewRequestBuilder.build(); try { mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException ex) { Log.d(TAG, "AUTO FOCUS FAILURE: " + ex); } } else { process(result); } }
Example #5
Source File: ImageCaptureManager.java From Camera2 with Apache License 2.0 | 6 votes |
/** * Tries to capture a pinned image for the given key from the ring-buffer. * * @return the pair of (image, captureResult) if image is found, null * otherwise. */ public Pair<Image, TotalCaptureResult> tryCapturePinnedImage(long timestamp) { final Pair<Long, CapturedImage> toCapture = mCapturedImageBuffer.tryGetPinned(timestamp); Image pinnedImage = null; TotalCaptureResult imageCaptureResult = null; // Return an Image if (toCapture != null && toCapture.second != null) { pinnedImage = toCapture.second.tryGetImage(); imageCaptureResult = toCapture.second.tryGetMetadata(); } return Pair.create(pinnedImage, imageCaptureResult); }
Example #6
Source File: RepeatFailureDetector.java From Camera2 with Apache License 2.0 | 6 votes |
@Override public void onCompleted(TotalCaptureResult result) { mConsecutiveErrorCount = 0; if (mFailureLevel > 0) { if (result.getFrameNumber() > mFailureFrameNumber) { // Success! Recovery worked, and a frame was completed // successfully. mRecoverySuccessCallback.onCallback(mRecoveryStrategies.get(mFailureLevel) .toString()); mFailureLevel = 0; mFailureFrameNumber = -1; } } }
Example #7
Source File: ResponseListeners.java From Camera2 with Apache License 2.0 | 6 votes |
/** * @param callback A thread-safe callback to receive partial and final * metadata for each frame. Metadata may be received * out-of-order. */ public static ResponseListener forPartialMetadata(final Updatable<CaptureResultProxy> callback) { return new ResponseListenerBase<CaptureResultProxy>(callback) { @Override public void onProgressed(CaptureResult partialResult) { callback.update(new AndroidCaptureResultProxy(partialResult)); } @Override public void onCompleted(TotalCaptureResult result) { callback.update(new AndroidTotalCaptureResultProxy(result)); } }; }
Example #8
Source File: ImageMetadataSynchronizer.java From libsoftwaresync with Apache License 2.0 | 6 votes |
/** * Enforces the invariant by sweeping all internal queues when a TotalCaptureResult arrives. * result cannot be null. */ private void handleCaptureResultLocked(TotalCaptureResult result) { // TODO(jiawen): Add annotations. CaptureRequestTag crt = CaptureRequestTag.getCaptureRequestTag(result); if (crt == null) { throw new IllegalArgumentException("CaptureResult is missing a CaptureRequestTag."); } // It has no targets, doesn't affect the queue. if (crt.targets.isEmpty()) { return; } pendingCaptureResultQueue.addLast(result); sweepQueuesLocked(); }
Example #9
Source File: Camera2Source.java From Machine-Learning-Projects-for-Mobile-Applications with MIT License | 5 votes |
/** * Capture a still picture. This method should be called when we get a response in * {@link #mCaptureCallback} from both {@link #lockFocus()}. */ private void captureStillPicture() { try { if (null == mCameraDevice) { return; } if (mShutterCallback != null) { mShutterCallback.onShutter(); } // This is the CaptureRequest.Builder that we use to take a picture. final CaptureRequest.Builder captureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); captureBuilder.addTarget(mImageReaderStill.getSurface()); // Use the same AE and AF modes as the preview. captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mFocusMode); if (mFlashSupported) { captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, mFlashMode); } // Orientation captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(mDisplayOrientation)); CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { unlockFocus(); } }; mCaptureSession.stopRepeating(); mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #10
Source File: Camera2RawFragment.java From android-Camera2Raw with Apache License 2.0 | 5 votes |
@Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { int requestId = (int) request.getTag(); ImageSaver.ImageSaverBuilder jpegBuilder; ImageSaver.ImageSaverBuilder rawBuilder; StringBuilder sb = new StringBuilder(); // Look up the ImageSaverBuilder for this request and update it with the CaptureResult synchronized (mCameraStateLock) { jpegBuilder = mJpegResultQueue.get(requestId); rawBuilder = mRawResultQueue.get(requestId); if (jpegBuilder != null) { jpegBuilder.setResult(result); sb.append("Saving JPEG as: "); sb.append(jpegBuilder.getSaveLocation()); } if (rawBuilder != null) { rawBuilder.setResult(result); if (jpegBuilder != null) sb.append(", "); sb.append("Saving RAW as: "); sb.append(rawBuilder.getSaveLocation()); } // If we have all the results necessary, save the image to a file in the background. handleCompletionLocked(requestId, jpegBuilder, mJpegResultQueue); handleCompletionLocked(requestId, rawBuilder, mRawResultQueue); finishedCaptureLocked(); } showToast(sb.toString()); }
Example #11
Source File: MetadataResponseListener.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public void onCompleted(TotalCaptureResult totalCaptureResult) { V newValue = totalCaptureResult.get(mKey); if (newValue != null) { mUpdatable.update(newValue); } }
Example #12
Source File: DoorbellCamera.java From doorbell with Apache License 2.0 | 5 votes |
@Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { if (session != null) { session.close(); mCaptureSession = null; Log.d(TAG, "CaptureSession closed"); } }
Example #13
Source File: MainActivity.java From Android-9-Development-Cookbook with MIT License | 5 votes |
@Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { super.onCaptureCompleted(session, request, result); Toast.makeText(MainActivity.this, "Picture Saved", Toast.LENGTH_SHORT).show(); startPreview(session); }
Example #14
Source File: CameraNew.java From aurora-imui with MIT License | 5 votes |
/** * Capture a still picture. This method should be called when we get a response in * {@link #mCaptureCallback} from both {@link #lockFocus()}. */ private void captureStillPicture() { try { final Activity activity = (Activity) mContext; if (null == activity || null == mCamera) { return; } // This is the CaptureRequest.Builder that we use to take a picture. final CaptureRequest.Builder captureBuilder = mCamera.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); setAutoFlash(captureBuilder); // Orientation // captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, // mCameraCharacteristic.get(CameraCharacteristics.SENSOR_ORIENTATION)); CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { unlockFocus(); } }; mCaptureSession.stopRepeating(); mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #15
Source File: CameraTexture2.java From PHONK with GNU General Public License v3.0 | 5 votes |
private void captureStillPicture() { MLog.d(TAG, "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()); // Use the same AE and AF modes as the preview. captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); // setAutoFlash(captureBuilder); // Orientation captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, 0); CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { Log.d(TAG, "saved to: "); // + mFile.toString()); unlockFocus(); } }; mCaptureSession.stopRepeating(); mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #16
Source File: Camera2Source.java From Camera2Vision with Apache License 2.0 | 5 votes |
/** * Capture a still picture. This method should be called when we get a response in * {@link #mCaptureCallback} from both {@link #lockFocus()}. */ private void captureStillPicture() { try { if (null == mCameraDevice) { return; } if(mShutterCallback != null) { mShutterCallback.onShutter(); } // This is the CaptureRequest.Builder that we use to take a picture. final CaptureRequest.Builder captureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE); captureBuilder.addTarget(mImageReaderStill.getSurface()); // Use the same AE and AF modes as the preview. captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mFocusMode); if(mFlashSupported) { captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, mFlashMode); } // Orientation captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(mDisplayOrientation)); CameraCaptureSession.CaptureCallback CaptureCallback = new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { unlockFocus(); } }; mCaptureSession.stopRepeating(); mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #17
Source File: CameraHandler.java From androidthings-imageclassifier with Apache License 2.0 | 5 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { session.close(); mCaptureSession = null; Log.d(TAG, "CaptureSession closed"); }
Example #18
Source File: CameraHandler.java From androidthings-imageclassifier with Apache License 2.0 | 5 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { session.close(); mCaptureSession = null; Log.d(TAG, "CaptureSession closed"); }
Example #19
Source File: CameraHandler.java From androidthings-imageclassifier with Apache License 2.0 | 5 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { session.close(); mCaptureSession = null; Log.d(TAG, "CaptureSession closed"); }
Example #20
Source File: CaptureCallback.java From android-robocar with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { super.onCaptureCompleted(session, request, result); Timber.d("Capture completed."); this.session = null; }
Example #21
Source File: ImageCaptureManager.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Returs the timestamp of the image if present, -1 otherwise. */ public long tryGetTimestamp() { if (mImage != null) { return mImage.getTimestamp(); } if (mMetadata != null) { return mMetadata.get(TotalCaptureResult.SENSOR_TIMESTAMP); } return -1; }
Example #22
Source File: ImageCaptureManager.java From Camera2 with Apache License 2.0 | 5 votes |
private boolean doMetaDataSwap(final TotalCaptureResult newMetadata, final long timestamp) { return mCapturedImageBuffer.swapLeast(timestamp, new SwapTask<CapturedImage>() { @Override public CapturedImage create() { CapturedImage image = new CapturedImage(); image.addMetadata(newMetadata); return image; } @Override public CapturedImage swap(CapturedImage oldElement) { oldElement.reset(); oldElement.addMetadata(newMetadata); return oldElement; } @Override public void update(CapturedImage existingElement) { existingElement.addMetadata(newMetadata); } @Override public long getSwapKey() { return -1; } }); }
Example #23
Source File: Camera2Fragment.java From MultiMediaSample with Apache License 2.0 | 5 votes |
/** * Capture a still picture. This method should be called when we get a response in * {@link #mCaptureCallback} from both {@link #lockFocus()}. */ 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); 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("拍照成功,图片保存为: " + mFile); Log.d(TAG, mFile.toString()); unlockFocus(); } }; mCaptureSession.stopRepeating(); mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #24
Source File: ResponseListeners.java From Camera2 with Apache License 2.0 | 5 votes |
/** * @param callback A thread-safe callback to receive the final metadata for * each frame. Metadata will always be received in-order. */ public static ResponseListener forFinalMetadata( final Updatable<TotalCaptureResultProxy> callback) { return new ResponseListenerBase<TotalCaptureResultProxy>(callback) { @Override public void onCompleted(TotalCaptureResult result) { callback.update(new AndroidTotalCaptureResultProxy(result)); } }; }
Example #25
Source File: ResponseListenerBroadcaster.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public void onCompleted(TotalCaptureResult result) { for (ResponseListener listener : mListeners) { listener.onCompleted(result); } }
Example #26
Source File: TagDispatchCaptureSession.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public void onCaptureCompleted(CameraCaptureSessionProxy session, CaptureRequest request, TotalCaptureResult result) { Object tag = request.getTag(); mListeners.get(tag).onCompleted(result); }
Example #27
Source File: Camera2.java From SimpleVideoEditor with Apache License 2.0 | 5 votes |
/** * Captures a still picture. */ void captureStillPicture() { try { CaptureRequest.Builder captureRequestBuilder = mCamera.createCaptureRequest( CameraDevice.TEMPLATE_STILL_CAPTURE); captureRequestBuilder.addTarget(mImageReader.getSurface()); captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, mCaptureRequestBuilder.get(CaptureRequest.CONTROL_AF_MODE)); updateFlashLightState(); // Calculate JPEG orientation. @SuppressWarnings("ConstantConditions") int sensorOrientation = mCameraCharacteristics.get( CameraCharacteristics.SENSOR_ORIENTATION); captureRequestBuilder.set(CaptureRequest.JPEG_ORIENTATION, (sensorOrientation + mDisplayOrientation * (mConfig.getCurrentFacing() == Constants.CAMERA_FACING_FRONT ? 1 : -1) + 360) % 360); // Stop preview and capture a still picture. mCaptureSession.stopRepeating(); mCaptureSession.capture(captureRequestBuilder.build(), new CameraCaptureSession.CaptureCallback() { @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { unlockFocus(); } }, null); } catch (CameraAccessException e) { Log.e(TAG, "Cannot capture a still picture.", e); } }
Example #28
Source File: CameraRecordActivity.java From ScreenCapture with MIT License | 4 votes |
@Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { process(result); }
Example #29
Source File: CameraFragment.java From io2015-codelabs with Apache License 2.0 | 4 votes |
@Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { Log.d(TAG, "onCaptureCompleted: "); process(result); }
Example #30
Source File: CameraConnectionFragment.java From fritz-examples with MIT License | 4 votes |
@Override public void onCaptureCompleted( final CameraCaptureSession session, final CaptureRequest request, final TotalCaptureResult result) { }