use of android.hardware.camera2.TotalCaptureResult in project android_frameworks_base by crdroidandroid.
the class Camera2ReprocessCaptureTest method doMixedReprocessBurstCapture.
/**
* Do a burst of captures that are mixed with regular and reprocess captures.
*
* @param isReprocessCaptures An array whose elements indicate whether it's a reprocess capture
* request. If the element is true, it represents a reprocess capture
* request. If the element is false, it represents a regular capture
* request. The size of the array is the number of capture requests
* in the burst.
*/
private ImageResultHolder[] doMixedReprocessBurstCapture(boolean[] isReprocessCaptures) throws Exception {
if (isReprocessCaptures == null || isReprocessCaptures.length <= 0) {
throw new IllegalArgumentException("isReprocessCaptures must have at least 1 capture.");
}
boolean hasReprocessRequest = false;
boolean hasRegularRequest = false;
TotalCaptureResult[] results = new TotalCaptureResult[isReprocessCaptures.length];
for (int i = 0; i < isReprocessCaptures.length; i++) {
// submit a capture and get the result if this entry is a reprocess capture.
if (isReprocessCaptures[i]) {
results[i] = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
null);
mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
hasReprocessRequest = true;
} else {
hasRegularRequest = true;
}
}
Surface[] outputSurfaces = new Surface[isReprocessCaptures.length];
for (int i = 0; i < isReprocessCaptures.length; i++) {
outputSurfaces[i] = getReprocessOutputImageReader().getSurface();
}
TotalCaptureResult[] finalResults = submitMixedCaptureBurstRequest(outputSurfaces, results);
ImageResultHolder[] holders = new ImageResultHolder[isReprocessCaptures.length];
for (int i = 0; i < isReprocessCaptures.length; i++) {
Image image = getReprocessOutputImageReaderListener().getImage(CAPTURE_TIMEOUT_MS);
if (hasReprocessRequest && hasRegularRequest) {
// If there are mixed requests, images and results may not be in the same order.
for (int j = 0; j < finalResults.length; j++) {
if (finalResults[j] != null && finalResults[j].get(CaptureResult.SENSOR_TIMESTAMP) == image.getTimestamp()) {
holders[i] = new ImageResultHolder(image, finalResults[j]);
finalResults[j] = null;
break;
}
}
assertNotNull("Cannot find a result matching output image's timestamp: " + image.getTimestamp(), holders[i]);
} else {
// If no mixed requests, images and results should be in the same order.
holders[i] = new ImageResultHolder(image, finalResults[i]);
}
}
return holders;
}
Aggregations