Search in sources :

Example 51 with TotalCaptureResult

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;
}
Also used : TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CameraTestUtils.getDataFromImage(com.android.mediaframeworktest.helpers.CameraTestUtils.getDataFromImage) Image(android.media.Image) Surface(android.view.Surface)

Aggregations

TotalCaptureResult (android.hardware.camera2.TotalCaptureResult)46 Image (android.media.Image)30 CameraTestUtils.getDataFromImage (com.android.mediaframeworktest.helpers.CameraTestUtils.getDataFromImage)30 ArrayList (java.util.ArrayList)30 CaptureRequest (android.hardware.camera2.CaptureRequest)26 SimpleCaptureCallback (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)25 CaptureFailure (android.hardware.camera2.CaptureFailure)5 PublicKey (android.hardware.camera2.impl.PublicKey)5 SyntheticKey (android.hardware.camera2.impl.SyntheticKey)5 Size (android.util.Size)5 Surface (android.view.Surface)5 Field (java.lang.reflect.Field)5 Activity (android.app.Activity)1 Point (android.graphics.Point)1 CameraAccessException (android.hardware.camera2.CameraAccessException)1 CameraCaptureSession (android.hardware.camera2.CameraCaptureSession)1 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)1 CameraManager (android.hardware.camera2.CameraManager)1 NonNull (android.support.annotation.NonNull)1