Search in sources :

Example 1 with CaptureFailure

use of android.hardware.camera2.CaptureFailure in project android_frameworks_base by ResurrectionRemix.

the class Camera2ReprocessCaptureTest method testReprocessAbort.

/**
     * Test aborting a burst reprocess capture and multiple single reprocess captures.
     */
private void testReprocessAbort(String cameraId, Size inputSize, int inputFormat, Size reprocessOutputSize, int reprocessOutputFormat) throws Exception {
    if (VERBOSE) {
        Log.v(TAG, "testReprocessAbort: cameraId: " + cameraId + " inputSize: " + inputSize + " inputFormat: " + inputFormat + " reprocessOutputSize: " + reprocessOutputSize + " reprocessOutputFormat: " + reprocessOutputFormat);
    }
    try {
        setupImageReaders(inputSize, inputFormat, reprocessOutputSize, reprocessOutputFormat, NUM_REPROCESS_CAPTURES);
        setupReprocessableSession(/*previewSurface*/
        null, NUM_REPROCESS_CAPTURES);
        // Test two cases: submitting reprocess requests one by one and in a burst.
        boolean[] submitInBursts = { false, true };
        for (boolean submitInBurst : submitInBursts) {
            // Prepare reprocess capture requests.
            ArrayList<CaptureRequest> reprocessRequests = new ArrayList<>(NUM_REPROCESS_CAPTURES);
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                TotalCaptureResult result = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
                null);
                mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
                CaptureRequest.Builder builder = mCamera.createReprocessCaptureRequest(result);
                builder.addTarget(getReprocessOutputImageReader().getSurface());
                reprocessRequests.add(builder.build());
            }
            SimpleCaptureCallback captureCallback = new SimpleCaptureCallback();
            // Submit reprocess capture requests.
            if (submitInBurst) {
                mSession.captureBurst(reprocessRequests, captureCallback, mHandler);
            } else {
                for (CaptureRequest request : reprocessRequests) {
                    mSession.capture(request, captureCallback, mHandler);
                }
            }
            // Abort after getting the first result
            TotalCaptureResult reprocessResult = captureCallback.getTotalCaptureResultForRequest(reprocessRequests.get(0), CAPTURE_TIMEOUT_FRAMES);
            mSession.abortCaptures();
            // Wait until the session is ready again.
            mSessionListener.getStateWaiter().waitForState(BlockingSessionCallback.SESSION_READY, SESSION_CLOSE_TIMEOUT_MS);
            // Gather all failed requests.
            ArrayList<CaptureFailure> failures = captureCallback.getCaptureFailures(NUM_REPROCESS_CAPTURES - 1);
            ArrayList<CaptureRequest> failedRequests = new ArrayList<>();
            for (CaptureFailure failure : failures) {
                failedRequests.add(failure.getRequest());
            }
            // For each request that didn't fail must have a valid result.
            for (int i = 1; i < reprocessRequests.size(); i++) {
                CaptureRequest request = reprocessRequests.get(i);
                if (!failedRequests.contains(request)) {
                    captureCallback.getTotalCaptureResultForRequest(request, CAPTURE_TIMEOUT_FRAMES);
                }
            }
            // Drain the image reader listeners.
            mFirstImageReaderListener.drain();
            if (!mShareOneImageReader) {
                mSecondImageReaderListener.drain();
            }
            // Make sure all input surfaces are released.
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                mImageWriterListener.waitForImageReleased(CAPTURE_TIMEOUT_MS);
            }
        }
    } finally {
        closeReprossibleSession();
        closeImageReaders();
    }
}
Also used : CaptureFailure(android.hardware.camera2.CaptureFailure) ArrayList(java.util.ArrayList) TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CaptureRequest(android.hardware.camera2.CaptureRequest) SimpleCaptureCallback(com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)

Example 2 with CaptureFailure

use of android.hardware.camera2.CaptureFailure in project android_frameworks_base by DirtyUnicorns.

the class Camera2ReprocessCaptureTest method testReprocessAbort.

/**
     * Test aborting a burst reprocess capture and multiple single reprocess captures.
     */
private void testReprocessAbort(String cameraId, Size inputSize, int inputFormat, Size reprocessOutputSize, int reprocessOutputFormat) throws Exception {
    if (VERBOSE) {
        Log.v(TAG, "testReprocessAbort: cameraId: " + cameraId + " inputSize: " + inputSize + " inputFormat: " + inputFormat + " reprocessOutputSize: " + reprocessOutputSize + " reprocessOutputFormat: " + reprocessOutputFormat);
    }
    try {
        setupImageReaders(inputSize, inputFormat, reprocessOutputSize, reprocessOutputFormat, NUM_REPROCESS_CAPTURES);
        setupReprocessableSession(/*previewSurface*/
        null, NUM_REPROCESS_CAPTURES);
        // Test two cases: submitting reprocess requests one by one and in a burst.
        boolean[] submitInBursts = { false, true };
        for (boolean submitInBurst : submitInBursts) {
            // Prepare reprocess capture requests.
            ArrayList<CaptureRequest> reprocessRequests = new ArrayList<>(NUM_REPROCESS_CAPTURES);
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                TotalCaptureResult result = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
                null);
                mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
                CaptureRequest.Builder builder = mCamera.createReprocessCaptureRequest(result);
                builder.addTarget(getReprocessOutputImageReader().getSurface());
                reprocessRequests.add(builder.build());
            }
            SimpleCaptureCallback captureCallback = new SimpleCaptureCallback();
            // Submit reprocess capture requests.
            if (submitInBurst) {
                mSession.captureBurst(reprocessRequests, captureCallback, mHandler);
            } else {
                for (CaptureRequest request : reprocessRequests) {
                    mSession.capture(request, captureCallback, mHandler);
                }
            }
            // Abort after getting the first result
            TotalCaptureResult reprocessResult = captureCallback.getTotalCaptureResultForRequest(reprocessRequests.get(0), CAPTURE_TIMEOUT_FRAMES);
            mSession.abortCaptures();
            // Wait until the session is ready again.
            mSessionListener.getStateWaiter().waitForState(BlockingSessionCallback.SESSION_READY, SESSION_CLOSE_TIMEOUT_MS);
            // Gather all failed requests.
            ArrayList<CaptureFailure> failures = captureCallback.getCaptureFailures(NUM_REPROCESS_CAPTURES - 1);
            ArrayList<CaptureRequest> failedRequests = new ArrayList<>();
            for (CaptureFailure failure : failures) {
                failedRequests.add(failure.getRequest());
            }
            // For each request that didn't fail must have a valid result.
            for (int i = 1; i < reprocessRequests.size(); i++) {
                CaptureRequest request = reprocessRequests.get(i);
                if (!failedRequests.contains(request)) {
                    captureCallback.getTotalCaptureResultForRequest(request, CAPTURE_TIMEOUT_FRAMES);
                }
            }
            // Drain the image reader listeners.
            mFirstImageReaderListener.drain();
            if (!mShareOneImageReader) {
                mSecondImageReaderListener.drain();
            }
            // Make sure all input surfaces are released.
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                mImageWriterListener.waitForImageReleased(CAPTURE_TIMEOUT_MS);
            }
        }
    } finally {
        closeReprossibleSession();
        closeImageReaders();
    }
}
Also used : CaptureFailure(android.hardware.camera2.CaptureFailure) ArrayList(java.util.ArrayList) TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CaptureRequest(android.hardware.camera2.CaptureRequest) SimpleCaptureCallback(com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)

Example 3 with CaptureFailure

use of android.hardware.camera2.CaptureFailure in project platform_frameworks_base by android.

the class Camera2ReprocessCaptureTest method testReprocessAbort.

/**
     * Test aborting a burst reprocess capture and multiple single reprocess captures.
     */
private void testReprocessAbort(String cameraId, Size inputSize, int inputFormat, Size reprocessOutputSize, int reprocessOutputFormat) throws Exception {
    if (VERBOSE) {
        Log.v(TAG, "testReprocessAbort: cameraId: " + cameraId + " inputSize: " + inputSize + " inputFormat: " + inputFormat + " reprocessOutputSize: " + reprocessOutputSize + " reprocessOutputFormat: " + reprocessOutputFormat);
    }
    try {
        setupImageReaders(inputSize, inputFormat, reprocessOutputSize, reprocessOutputFormat, NUM_REPROCESS_CAPTURES);
        setupReprocessableSession(/*previewSurface*/
        null, NUM_REPROCESS_CAPTURES);
        // Test two cases: submitting reprocess requests one by one and in a burst.
        boolean[] submitInBursts = { false, true };
        for (boolean submitInBurst : submitInBursts) {
            // Prepare reprocess capture requests.
            ArrayList<CaptureRequest> reprocessRequests = new ArrayList<>(NUM_REPROCESS_CAPTURES);
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                TotalCaptureResult result = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
                null);
                mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
                CaptureRequest.Builder builder = mCamera.createReprocessCaptureRequest(result);
                builder.addTarget(getReprocessOutputImageReader().getSurface());
                reprocessRequests.add(builder.build());
            }
            SimpleCaptureCallback captureCallback = new SimpleCaptureCallback();
            // Submit reprocess capture requests.
            if (submitInBurst) {
                mSession.captureBurst(reprocessRequests, captureCallback, mHandler);
            } else {
                for (CaptureRequest request : reprocessRequests) {
                    mSession.capture(request, captureCallback, mHandler);
                }
            }
            // Abort after getting the first result
            TotalCaptureResult reprocessResult = captureCallback.getTotalCaptureResultForRequest(reprocessRequests.get(0), CAPTURE_TIMEOUT_FRAMES);
            mSession.abortCaptures();
            // Wait until the session is ready again.
            mSessionListener.getStateWaiter().waitForState(BlockingSessionCallback.SESSION_READY, SESSION_CLOSE_TIMEOUT_MS);
            // Gather all failed requests.
            ArrayList<CaptureFailure> failures = captureCallback.getCaptureFailures(NUM_REPROCESS_CAPTURES - 1);
            ArrayList<CaptureRequest> failedRequests = new ArrayList<>();
            for (CaptureFailure failure : failures) {
                failedRequests.add(failure.getRequest());
            }
            // For each request that didn't fail must have a valid result.
            for (int i = 1; i < reprocessRequests.size(); i++) {
                CaptureRequest request = reprocessRequests.get(i);
                if (!failedRequests.contains(request)) {
                    captureCallback.getTotalCaptureResultForRequest(request, CAPTURE_TIMEOUT_FRAMES);
                }
            }
            // Drain the image reader listeners.
            mFirstImageReaderListener.drain();
            if (!mShareOneImageReader) {
                mSecondImageReaderListener.drain();
            }
            // Make sure all input surfaces are released.
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                mImageWriterListener.waitForImageReleased(CAPTURE_TIMEOUT_MS);
            }
        }
    } finally {
        closeReprossibleSession();
        closeImageReaders();
    }
}
Also used : CaptureFailure(android.hardware.camera2.CaptureFailure) ArrayList(java.util.ArrayList) TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CaptureRequest(android.hardware.camera2.CaptureRequest) SimpleCaptureCallback(com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)

Example 4 with CaptureFailure

use of android.hardware.camera2.CaptureFailure in project android_frameworks_base by crdroidandroid.

the class Camera2ReprocessCaptureTest method testReprocessAbort.

/**
     * Test aborting a burst reprocess capture and multiple single reprocess captures.
     */
private void testReprocessAbort(String cameraId, Size inputSize, int inputFormat, Size reprocessOutputSize, int reprocessOutputFormat) throws Exception {
    if (VERBOSE) {
        Log.v(TAG, "testReprocessAbort: cameraId: " + cameraId + " inputSize: " + inputSize + " inputFormat: " + inputFormat + " reprocessOutputSize: " + reprocessOutputSize + " reprocessOutputFormat: " + reprocessOutputFormat);
    }
    try {
        setupImageReaders(inputSize, inputFormat, reprocessOutputSize, reprocessOutputFormat, NUM_REPROCESS_CAPTURES);
        setupReprocessableSession(/*previewSurface*/
        null, NUM_REPROCESS_CAPTURES);
        // Test two cases: submitting reprocess requests one by one and in a burst.
        boolean[] submitInBursts = { false, true };
        for (boolean submitInBurst : submitInBursts) {
            // Prepare reprocess capture requests.
            ArrayList<CaptureRequest> reprocessRequests = new ArrayList<>(NUM_REPROCESS_CAPTURES);
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                TotalCaptureResult result = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
                null);
                mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
                CaptureRequest.Builder builder = mCamera.createReprocessCaptureRequest(result);
                builder.addTarget(getReprocessOutputImageReader().getSurface());
                reprocessRequests.add(builder.build());
            }
            SimpleCaptureCallback captureCallback = new SimpleCaptureCallback();
            // Submit reprocess capture requests.
            if (submitInBurst) {
                mSession.captureBurst(reprocessRequests, captureCallback, mHandler);
            } else {
                for (CaptureRequest request : reprocessRequests) {
                    mSession.capture(request, captureCallback, mHandler);
                }
            }
            // Abort after getting the first result
            TotalCaptureResult reprocessResult = captureCallback.getTotalCaptureResultForRequest(reprocessRequests.get(0), CAPTURE_TIMEOUT_FRAMES);
            mSession.abortCaptures();
            // Wait until the session is ready again.
            mSessionListener.getStateWaiter().waitForState(BlockingSessionCallback.SESSION_READY, SESSION_CLOSE_TIMEOUT_MS);
            // Gather all failed requests.
            ArrayList<CaptureFailure> failures = captureCallback.getCaptureFailures(NUM_REPROCESS_CAPTURES - 1);
            ArrayList<CaptureRequest> failedRequests = new ArrayList<>();
            for (CaptureFailure failure : failures) {
                failedRequests.add(failure.getRequest());
            }
            // For each request that didn't fail must have a valid result.
            for (int i = 1; i < reprocessRequests.size(); i++) {
                CaptureRequest request = reprocessRequests.get(i);
                if (!failedRequests.contains(request)) {
                    captureCallback.getTotalCaptureResultForRequest(request, CAPTURE_TIMEOUT_FRAMES);
                }
            }
            // Drain the image reader listeners.
            mFirstImageReaderListener.drain();
            if (!mShareOneImageReader) {
                mSecondImageReaderListener.drain();
            }
            // Make sure all input surfaces are released.
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                mImageWriterListener.waitForImageReleased(CAPTURE_TIMEOUT_MS);
            }
        }
    } finally {
        closeReprossibleSession();
        closeImageReaders();
    }
}
Also used : CaptureFailure(android.hardware.camera2.CaptureFailure) ArrayList(java.util.ArrayList) TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CaptureRequest(android.hardware.camera2.CaptureRequest) SimpleCaptureCallback(com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)

Example 5 with CaptureFailure

use of android.hardware.camera2.CaptureFailure in project android_frameworks_base by AOSPA.

the class Camera2ReprocessCaptureTest method testReprocessAbort.

/**
     * Test aborting a burst reprocess capture and multiple single reprocess captures.
     */
private void testReprocessAbort(String cameraId, Size inputSize, int inputFormat, Size reprocessOutputSize, int reprocessOutputFormat) throws Exception {
    if (VERBOSE) {
        Log.v(TAG, "testReprocessAbort: cameraId: " + cameraId + " inputSize: " + inputSize + " inputFormat: " + inputFormat + " reprocessOutputSize: " + reprocessOutputSize + " reprocessOutputFormat: " + reprocessOutputFormat);
    }
    try {
        setupImageReaders(inputSize, inputFormat, reprocessOutputSize, reprocessOutputFormat, NUM_REPROCESS_CAPTURES);
        setupReprocessableSession(/*previewSurface*/
        null, NUM_REPROCESS_CAPTURES);
        // Test two cases: submitting reprocess requests one by one and in a burst.
        boolean[] submitInBursts = { false, true };
        for (boolean submitInBurst : submitInBursts) {
            // Prepare reprocess capture requests.
            ArrayList<CaptureRequest> reprocessRequests = new ArrayList<>(NUM_REPROCESS_CAPTURES);
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                TotalCaptureResult result = submitCaptureRequest(mFirstImageReader.getSurface(), /*inputResult*/
                null);
                mImageWriter.queueInputImage(mFirstImageReaderListener.getImage(CAPTURE_TIMEOUT_MS));
                CaptureRequest.Builder builder = mCamera.createReprocessCaptureRequest(result);
                builder.addTarget(getReprocessOutputImageReader().getSurface());
                reprocessRequests.add(builder.build());
            }
            SimpleCaptureCallback captureCallback = new SimpleCaptureCallback();
            // Submit reprocess capture requests.
            if (submitInBurst) {
                mSession.captureBurst(reprocessRequests, captureCallback, mHandler);
            } else {
                for (CaptureRequest request : reprocessRequests) {
                    mSession.capture(request, captureCallback, mHandler);
                }
            }
            // Abort after getting the first result
            TotalCaptureResult reprocessResult = captureCallback.getTotalCaptureResultForRequest(reprocessRequests.get(0), CAPTURE_TIMEOUT_FRAMES);
            mSession.abortCaptures();
            // Wait until the session is ready again.
            mSessionListener.getStateWaiter().waitForState(BlockingSessionCallback.SESSION_READY, SESSION_CLOSE_TIMEOUT_MS);
            // Gather all failed requests.
            ArrayList<CaptureFailure> failures = captureCallback.getCaptureFailures(NUM_REPROCESS_CAPTURES - 1);
            ArrayList<CaptureRequest> failedRequests = new ArrayList<>();
            for (CaptureFailure failure : failures) {
                failedRequests.add(failure.getRequest());
            }
            // For each request that didn't fail must have a valid result.
            for (int i = 1; i < reprocessRequests.size(); i++) {
                CaptureRequest request = reprocessRequests.get(i);
                if (!failedRequests.contains(request)) {
                    captureCallback.getTotalCaptureResultForRequest(request, CAPTURE_TIMEOUT_FRAMES);
                }
            }
            // Drain the image reader listeners.
            mFirstImageReaderListener.drain();
            if (!mShareOneImageReader) {
                mSecondImageReaderListener.drain();
            }
            // Make sure all input surfaces are released.
            for (int i = 0; i < NUM_REPROCESS_CAPTURES; i++) {
                mImageWriterListener.waitForImageReleased(CAPTURE_TIMEOUT_MS);
            }
        }
    } finally {
        closeReprossibleSession();
        closeImageReaders();
    }
}
Also used : CaptureFailure(android.hardware.camera2.CaptureFailure) ArrayList(java.util.ArrayList) TotalCaptureResult(android.hardware.camera2.TotalCaptureResult) CaptureRequest(android.hardware.camera2.CaptureRequest) SimpleCaptureCallback(com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)

Aggregations

CaptureFailure (android.hardware.camera2.CaptureFailure)9 CaptureRequest (android.hardware.camera2.CaptureRequest)9 TotalCaptureResult (android.hardware.camera2.TotalCaptureResult)9 ArrayList (java.util.ArrayList)7 SimpleCaptureCallback (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)5 CameraCaptureSession (android.hardware.camera2.CameraCaptureSession)4 CameraAccessException (android.hardware.camera2.CameraAccessException)2 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 CaptureCallback (android.hardware.camera2.CameraCaptureSession.CaptureCallback)1 MeteringRectangle (android.hardware.camera2.params.MeteringRectangle)1 Location (android.location.Location)1