ImageCapture.OnImageCapturedListener

public static abstract class ImageCapture.OnImageCapturedListener
extends Object

java.lang.Object
   ↳ androidx.camera.core.ImageCapture.OnImageCapturedListener


Listener called when an image capture has completed.

Summary

Public constructors

ImageCapture.OnImageCapturedListener()

Public methods

void onCaptureSuccess(ImageProxy image, int rotationDegrees)

Callback for when the image has been captured.

void onError(ImageCapture.ImageCaptureError imageCaptureError, String message, Throwable cause)

Callback for when an error occurred during image capture.

Inherited methods

Public constructors

ImageCapture.OnImageCapturedListener

public ImageCapture.OnImageCapturedListener ()

Public methods

onCaptureSuccess

public void onCaptureSuccess (ImageProxy image, 
                int rotationDegrees)

Callback for when the image has been captured.

The application is responsible for calling ImageProxy.close() to close the image.

The image is of format ImageFormat.JPEG, queryable via ImageProxy.getFormat().

The image is provided as captured by the underlying ImageReader without rotation applied. rotationDegrees describes the magnitude of clockwise rotation, which if applied to the image will make it match the currently configured target rotation.

For example, if the current target rotation is set to the display rotation, rotationDegrees is the rotation to apply to the image to match the display orientation. A rotation of 90 degrees would mean rotating the image 90 degrees clockwise produces an image that will match the display orientation.

See also ImageCaptureConfig.Builder.setTargetRotation(int) and ImageCapture.setTargetRotation(int).

Parameters
image ImageProxy: The captured image

rotationDegrees int: The rotation which if applied to the image will make it match the current target rotation. rotationDegrees is expressed as one of Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270.

onError

public void onError (ImageCapture.ImageCaptureError imageCaptureError, 
                String message, 
                Throwable cause)

Callback for when an error occurred during image capture.

Parameters
imageCaptureError ImageCapture.ImageCaptureError

message String

cause Throwable