Android APIs
public class

CaptureFailure

extends Object
java.lang.Object
   ↳ android.hardware.camera2.CaptureFailure

Class Overview

A report of failed capture for a single image capture from the image sensor.

CaptureFailures are produced by a CameraDevice if processing a CaptureRequest fails, either partially or fully. Use getReason() to determine the specific nature of the failed capture.

Receiving a CaptureFailure means that the metadata associated with that frame number has been dropped -- no CaptureResult with the same frame number will be produced.

Summary

Constants
int REASON_ERROR The CaptureResult has been dropped this frame only due to an error in the framework.
int REASON_FLUSHED The capture has failed due to a abortCaptures() call from the application.
Public Methods
long getFrameNumber()
Get the frame number associated with this failed capture.
int getReason()
Determine why the request was dropped, whether due to an error or to a user action.
CaptureRequest getRequest()
Get the request associated with this failed capture.
int getSequenceId()
The sequence ID for this failed capture that was returned by the capture(CaptureRequest, CameraCaptureSession.CaptureCallback, Handler) family of functions.
boolean wasImageCaptured()
Determine if the image was captured from the camera.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int REASON_ERROR

Added in API level 21

The CaptureResult has been dropped this frame only due to an error in the framework.

See Also
Constant Value: 0 (0x00000000)

public static final int REASON_FLUSHED

Added in API level 21

The capture has failed due to a abortCaptures() call from the application.

See Also
Constant Value: 1 (0x00000001)

Public Methods

public long getFrameNumber ()

Added in API level 21

Get the frame number associated with this failed capture.

Whenever a request has been processed, regardless of failed capture or success, it gets a unique frame number assigned to its future result/failed capture.

This value monotonically increments, starting with 0, for every new result or failure; and the scope is the lifetime of the CameraDevice.

Returns
  • long frame number

public int getReason ()

Added in API level 21

Determine why the request was dropped, whether due to an error or to a user action.

Returns
  • int One of REASON_* integer constants.

public CaptureRequest getRequest ()

Added in API level 21

Get the request associated with this failed capture.

Whenever a request is unsuccessfully captured, with onCaptureFailed(CameraCaptureSession, CaptureRequest, CaptureFailure), the failed capture's getRequest() will return that request.

In particular,

cameraDevice.capture(someRequest, new CaptureCallback() {
     @Override
     void onCaptureFailed(CaptureRequest myRequest, CaptureFailure myFailure) {
         assert(myFailure.getRequest.equals(myRequest) == true);
     }
 };
 

Returns
  • The request associated with this failed capture. Never null.

public int getSequenceId ()

Added in API level 21

The sequence ID for this failed capture that was returned by the capture(CaptureRequest, CameraCaptureSession.CaptureCallback, Handler) family of functions.

The sequence ID is a unique monotonically increasing value starting from 0, incremented every time a new group of requests is submitted to the CameraDevice.

Returns
  • int The ID for the sequence of requests that this capture failure is the result of

public boolean wasImageCaptured ()

Added in API level 21

Determine if the image was captured from the camera.

If the image was not captured, no image buffers will be available. If the image was captured, then image buffers may be available.

Returns
  • boolean True if the image was captured, false otherwise.