Java Code Examples for android.hardware.camera2.CaptureRequest#getTag()
The following examples show how to use
android.hardware.camera2.CaptureRequest#getTag() .
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: 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 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: Camera2RawFragment.java From android-Camera2Raw with Apache License 2.0 | 6 votes |
@Override public void onCaptureStarted(CameraCaptureSession session, CaptureRequest request, long timestamp, long frameNumber) { String currentDateTime = generateTimestamp(); File rawFile = new File(Environment. getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "RAW_" + currentDateTime + ".dng"); File jpegFile = new File(Environment. getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "JPEG_" + currentDateTime + ".jpg"); // Look up the ImageSaverBuilder for this request and update it with the file name // based on the capture start time. ImageSaver.ImageSaverBuilder jpegBuilder; ImageSaver.ImageSaverBuilder rawBuilder; int requestId = (int) request.getTag(); synchronized (mCameraStateLock) { jpegBuilder = mJpegResultQueue.get(requestId); rawBuilder = mRawResultQueue.get(requestId); } if (jpegBuilder != null) jpegBuilder.setFile(jpegFile); if (rawBuilder != null) rawBuilder.setFile(rawFile); }
Example 4
Source File: Camera2Source.java From Machine-Learning-Projects-for-Mobile-Applications with MIT License | 5 votes |
@Override public void onCaptureFailed(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull CaptureFailure failure) { if (request.getTag() == "FOCUS_TAG") { Log.d(TAG, "Manual AF failure: " + failure); mAutoFocusCallback.onAutoFocus(false); } }
Example 5
Source File: TagDispatchCaptureSession.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public void onCaptureStarted(CameraCaptureSessionProxy session, CaptureRequest request, long timestamp, long frameNumber) { Object tag = request.getTag(); mListeners.get(tag).onStarted(timestamp); }
Example 6
Source File: TagDispatchCaptureSession.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public void onCaptureProgressed(CameraCaptureSessionProxy session, CaptureRequest request, CaptureResult partialResult) { Object tag = request.getTag(); mListeners.get(tag).onProgressed(partialResult); }
Example 7
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 8
Source File: TagDispatchCaptureSession.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public void onCaptureFailed(CameraCaptureSessionProxy session, CaptureRequest request, CaptureFailure failure) { Object tag = request.getTag(); mListeners.get(tag).onFailed(failure); }
Example 9
Source File: Camera2Source.java From Camera2Vision with Apache License 2.0 | 5 votes |
@Override public void onCaptureFailed(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull CaptureFailure failure) { if(request.getTag() == "FOCUS_TAG") { Log.d(TAG, "Manual AF failure: "+failure); mAutoFocusCallback.onAutoFocus(false); } }
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: Camera2RawFragment.java From android-Camera2Raw with Apache License 2.0 | 5 votes |
@Override public void onCaptureFailed(CameraCaptureSession session, CaptureRequest request, CaptureFailure failure) { int requestId = (int) request.getTag(); synchronized (mCameraStateLock) { mJpegResultQueue.remove(requestId); mRawResultQueue.remove(requestId); finishedCaptureLocked(); } showToast("Capture failed!"); }
Example 12
Source File: HdrViewfinderActivity.java From android-HdrViewfinder with Apache License 2.0 | 4 votes |
public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { // Only update UI every so many frames // Use an odd number here to ensure both even and odd exposures get an occasional update long frameNumber = result.getFrameNumber(); if (frameNumber % 3 != 0) return; final Long exposureTime = result.get(CaptureResult.SENSOR_EXPOSURE_TIME); if (exposureTime == null) { throw new RuntimeException("Cannot get exposure time."); } // Format exposure time nicely String exposureText; if (exposureTime > ONE_SECOND) { exposureText = String.format(Locale.US, "%.2f s", exposureTime / 1e9); } else if (exposureTime > MILLI_SECOND) { exposureText = String.format(Locale.US, "%.2f ms", exposureTime / 1e6); } else if (exposureTime > MICRO_SECOND) { exposureText = String.format(Locale.US, "%.2f us", exposureTime / 1e3); } else { exposureText = String.format(Locale.US, "%d ns", exposureTime); } Object tag = request.getTag(); Log.i(TAG, "Exposure: " + exposureText); if (tag == mEvenExposureTag) { mEvenExposureText.setText(exposureText); mEvenExposureText.setEnabled(true); mOddExposureText.setEnabled(true); mAutoExposureText.setEnabled(false); } else if (tag == mOddExposureTag) { mOddExposureText.setText(exposureText); mEvenExposureText.setEnabled(true); mOddExposureText.setEnabled(true); mAutoExposureText.setEnabled(false); } else { mAutoExposureText.setText(exposureText); mEvenExposureText.setEnabled(false); mOddExposureText.setEnabled(false); mAutoExposureText.setEnabled(true); } }