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();
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations