Google berkomitmen untuk mendorong terwujudnya keadilan ras bagi komunitas Kulit Hitam. Lihat caranya.


interface Analyzer

Interface for analyzing images.

Implement Analyzer and pass it to ImageAnalysis#setAnalyzer(Executor, Analyzer) to receive images and perform custom processing by implementing the ImageAnalysis.Analyzer#analyze(ImageProxy) function.


Public methods
abstract Unit
analyze(@NonNull image: ImageProxy)

Analyzes an image to produce a result.

Public methods


abstract fun analyze(@NonNull image: ImageProxy): Unit

Analyzes an image to produce a result.

This method is called once for each image from the camera, and called at the frame rate of the camera. Each analyze call is executed sequentially.

It is the responsibility of the application to close the image once done with it. If the images are not closed then it may block further images from being produced (causing the preview to stall) or drop images as determined by the configured backpressure strategy. The exact behavior is configurable via ImageAnalysis.Builder#setBackpressureStrategy(int).

Images produced here will no longer be valid after the ImageAnalysis instance that produced it has been unbound from the camera.

The image provided has format

The provided image is typically in the orientation of the sensor, meaning CameraX does not perform an internal rotation of the data. The rotationDegrees parameter allows the analysis to understand the image orientation when processing or to apply a rotation. For example, if the target rotation) is natural orientation, rotationDegrees would be the rotation which would align the buffer data ordering to natural orientation.

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 implementation additional detail can be found in android.hardware.camera2.CameraDevice documentation.

image ImageProxy: The image to analyze