Java Examples for android.hardware.camera2.CameraCaptureSession.CaptureCallback
The following java examples will help you to understand the usage of android.hardware.camera2.CameraCaptureSession.CaptureCallback. These source code samples are taken from different open source projects.
Example 1
| Project: platform_frameworks_base-master File: Camera2SurfaceViewTestCase.java View source code |
/**
* Submit a capture {@code count} times, then submit additional captures in order to ensure that
* the camera will be synchronized.
*
* <p>
* The additional capture count is determined by android.sync.maxLatency (or
* a fixed {@value #NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY}) captures if maxLatency is unknown).
* </p>
*
* <p>Returns the number of captures that were submitted (at least 1), which is useful
* with {@link #waitForNumResults}.</p>
*
* @param request capture request to forward to {@link CameraDevice#capture}
* @param count the number of times to submit the request (minimally), must be at least 1
* @param listener request listener to forward to {@link CameraDevice#capture}
* @param handler handler to forward to {@link CameraDevice#capture}
*
* @return the number of captures that were submitted
*
* @throws IllegalArgumentException if {@code count} was not at least 1
* @throws CameraAccessException if capturing failed
*/
protected int captureRequestsSynchronized(CaptureRequest request, int count, CaptureCallback listener, Handler handler) throws CameraAccessException {
if (count < 1) {
throw new IllegalArgumentException("count must be positive");
}
int maxLatency = mStaticInfo.getSyncMaxLatency();
if (maxLatency == CameraMetadata.SYNC_MAX_LATENCY_UNKNOWN) {
maxLatency = NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY;
}
assertTrue("maxLatency is non-negative", maxLatency >= 0);
int numCaptures = maxLatency + count;
for (int i = 0; i < numCaptures; ++i) {
mSession.capture(request, listener, handler);
}
return numCaptures;
}Example 2
| Project: android-sdk-sources-for-api-level-23-master File: Camera2UtilsTest.java View source code |
private void captureListenerSplitterAllCallbacksReceived(CaptureCallback splitter, CaptureCallback... terminals) { splitter.onCaptureCompleted(null, null, null); for (CaptureCallback each : terminals) { verify(each).onCaptureCompleted(null, null, null); } splitter.onCaptureFailed(null, null, null); for (CaptureCallback each : terminals) { verify(each).onCaptureFailed(null, null, null); } splitter.onCaptureProgressed(null, null, null); for (CaptureCallback each : terminals) { verify(each).onCaptureProgressed(null, null, null); } splitter.onCaptureSequenceAborted(null, 0); for (CaptureCallback each : terminals) { verify(each).onCaptureSequenceAborted(null, 0); } splitter.onCaptureSequenceCompleted(null, 0, 0L); for (CaptureCallback each : terminals) { verify(each).onCaptureSequenceCompleted(null, 0, 0L); } splitter.onCaptureStarted(null, null, 0L, 1L); for (CaptureCallback each : terminals) { verify(each).onCaptureStarted(null, null, 0L, 1L); } }
Example 3
| Project: android_frameworks_base-master File: Camera2SurfaceViewTestCase.java View source code |
/**
* Submit a capture {@code count} times, then submit additional captures in order to ensure that
* the camera will be synchronized.
*
* <p>
* The additional capture count is determined by android.sync.maxLatency (or
* a fixed {@value #NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY}) captures if maxLatency is unknown).
* </p>
*
* <p>Returns the number of captures that were submitted (at least 1), which is useful
* with {@link #waitForNumResults}.</p>
*
* @param request capture request to forward to {@link CameraDevice#capture}
* @param count the number of times to submit the request (minimally), must be at least 1
* @param listener request listener to forward to {@link CameraDevice#capture}
* @param handler handler to forward to {@link CameraDevice#capture}
*
* @return the number of captures that were submitted
*
* @throws IllegalArgumentException if {@code count} was not at least 1
* @throws CameraAccessException if capturing failed
*/
protected int captureRequestsSynchronized(CaptureRequest request, int count, CaptureCallback listener, Handler handler) throws CameraAccessException {
if (count < 1) {
throw new IllegalArgumentException("count must be positive");
}
int maxLatency = mStaticInfo.getSyncMaxLatency();
if (maxLatency == CameraMetadata.SYNC_MAX_LATENCY_UNKNOWN) {
maxLatency = NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY;
}
assertTrue("maxLatency is non-negative", maxLatency >= 0);
int numCaptures = maxLatency + count;
for (int i = 0; i < numCaptures; ++i) {
mSession.capture(request, listener, handler);
}
return numCaptures;
}