OnImageCapturedCallback
abstract class OnImageCapturedCallback
kotlin.Any | |
↳ | androidx.camera.core.ImageCapture.OnImageCapturedCallback |
Callback for when an image capture has completed.
Summary
Public constructors | |
---|---|
<init>() Callback for when an image capture has completed. |
Public methods | |
---|---|
open Unit |
onCaptureSuccess(@NonNull image: ImageProxy) Callback for when the image has been captured. |
open Unit |
onError(@NonNull exception: ImageCaptureException) Callback for when an error occurred during image capture. |
Public constructors
<init>
OnImageCapturedCallback()
Callback for when an image capture has completed.
Public methods
onCaptureSuccess
open fun onCaptureSuccess(@NonNull image: ImageProxy): Unit
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. The value in image.getImageInfo().getRotationDegrees()
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 Builder#setTargetRotation(int)
and setTargetRotation(int)
.
Timestamps are in nanoseconds and monotonic and can be compared to timestamps from images produced from UseCases bound to the same camera instance. More detail is available depending on the implementation. For example with CameraX using a androidx.camera.camera2
implementation additional detail can be found in android.hardware.camera2.CameraDevice
documentation.
Parameters | |
---|---|
image |
ImageProxy: The captured image |
onError
open fun onError(@NonNull exception: ImageCaptureException): Unit
Callback for when an error occurred during image capture.
Parameters | |
---|---|
exception |
ImageCaptureException: An ImageCaptureException that contains the type of error, the error message and the throwable that caused it. |