ImageAnalysisConfig

public final class ImageAnalysisConfig
extends Object implements Config, UseCaseEventConfig

java.lang.Object
   ↳ androidx.camera.core.ImageAnalysisConfig


Configuration for an image analysis use case.

Summary

Nested classes

class ImageAnalysisConfig.Builder

Builder for a ImageAnalysisConfig

Public methods

Handler getCallbackHandler(Handler valueIfMissing)

Returns the default handler that will be used for callbacks.

Handler getCallbackHandler()

Returns the default handler that will be used for callbacks.

int getImageQueueDepth(int valueIfMissing)

Returns the number of images available to the camera pipeline.

int getImageQueueDepth()

Returns the number of images available to the camera pipeline.

ImageAnalysis.ImageReaderMode getImageReaderMode()

Returns the mode that the image is acquired from ImageReader.

ImageAnalysis.ImageReaderMode getImageReaderMode(ImageAnalysis.ImageReaderMode valueIfMissing)

Returns the mode that the image is acquired from ImageReader.

CameraX.LensFacing getLensFacing()

Retrieves the lens facing direction for the primary camera to be configured.

CameraX.LensFacing getLensFacing(CameraX.LensFacing valueIfMissing)

Returns the lens-facing direction of the camera being configured.

Rational getTargetAspectRatio(Rational valueIfMissing)

Retrieves the aspect ratio of the target intending to use images from this configuration.

Rational getTargetAspectRatio()

Retrieves the aspect ratio of the target intending to use images from this configuration.

String getTargetName()

Retrieves the name of the target object being configured.

String getTargetName(String valueIfMissing)

Retrieves the name of the target object being configured.

Size getTargetResolution(Size valueIfMissing)

Retrieves the resolution of the target intending to use from this configuration.

Size getTargetResolution()

Retrieves the resolution of the target intending to use from this configuration.

int getTargetRotation()

Retrieves the rotation of the target intending to use images from this configuration.

int getTargetRotation(int valueIfMissing)

Retrieves the rotation of the target intending to use images from this configuration.

Inherited methods

Public methods

getCallbackHandler

public Handler getCallbackHandler (Handler valueIfMissing)

Returns the default handler that will be used for callbacks.

Parameters
valueIfMissing Handler: The value to return if this configuration option has not been set.

Returns
Handler The stored value or valueIfMissing if the value does not exist in this configuration.

getCallbackHandler

public Handler getCallbackHandler ()

Returns the default handler that will be used for callbacks.

Returns
Handler The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getImageQueueDepth

public int getImageQueueDepth (int valueIfMissing)

Returns the number of images available to the camera pipeline.

The image queue depth is the total number of images, including the image being analyzed, available to the camera pipeline. If analysis takes long enough, the image queue may become full and stall the camera pipeline.

Parameters
valueIfMissing int: The value to return if this configuration option has not been set.

Returns
int The stored value or valueIfMissing if the value does not exist in this configuration.

getImageQueueDepth

public int getImageQueueDepth ()

Returns the number of images available to the camera pipeline.

The image queue depth is the total number of images, including the image being analyzed, available to the camera pipeline. If analysis takes long enough, the image queue may become full and stall the camera pipeline.

Returns
int The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getImageReaderMode

public ImageAnalysis.ImageReaderMode getImageReaderMode ()

Returns the mode that the image is acquired from ImageReader.

The available values are ImageAnalysis.ImageReaderMode.ACQUIRE_NEXT_IMAGE and ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE.

Returns
ImageAnalysis.ImageReaderMode The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getImageReaderMode

public ImageAnalysis.ImageReaderMode getImageReaderMode (ImageAnalysis.ImageReaderMode valueIfMissing)

Returns the mode that the image is acquired from ImageReader.

The available values are ImageAnalysis.ImageReaderMode.ACQUIRE_NEXT_IMAGE and ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE.

Parameters
valueIfMissing ImageAnalysis.ImageReaderMode: The value to return if this configuration option has not been set.

Returns
ImageAnalysis.ImageReaderMode The stored value or valueIfMissing if the value does not exist in this configuration.

getLensFacing

public CameraX.LensFacing getLensFacing ()

Retrieves the lens facing direction for the primary camera to be configured.

Returns
CameraX.LensFacing The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getLensFacing

public CameraX.LensFacing getLensFacing (CameraX.LensFacing valueIfMissing)

Returns the lens-facing direction of the camera being configured.

Parameters
valueIfMissing CameraX.LensFacing: The value to return if this configuration option has not been set.

Returns
CameraX.LensFacing The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetAspectRatio

public Rational getTargetAspectRatio (Rational valueIfMissing)

Retrieves the aspect ratio of the target intending to use images from this configuration.

This is the ratio of the target's width to the image's height, where the numerator of the provided Rational corresponds to the width, and the denominator corresponds to the height.

Parameters
valueIfMissing Rational: The value to return if this configuration option has not been set.

Returns
Rational The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetAspectRatio

public Rational getTargetAspectRatio ()

Retrieves the aspect ratio of the target intending to use images from this configuration.

This is the ratio of the target's width to the image's height, where the numerator of the provided Rational corresponds to the width, and the denominator corresponds to the height.

Returns
Rational The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getTargetName

public String getTargetName ()

Retrieves the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Returns
String The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getTargetName

public String getTargetName (String valueIfMissing)

Retrieves the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Parameters
valueIfMissing String: The value to return if this configuration option has not been set.

Returns
String The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetResolution

public Size getTargetResolution (Size valueIfMissing)

Retrieves the resolution of the target intending to use from this configuration.

Parameters
valueIfMissing Size: The value to return if this configuration option has not been set.

Returns
Size The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetResolution

public Size getTargetResolution ()

Retrieves the resolution of the target intending to use from this configuration.

Returns
Size The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getTargetRotation

public int getTargetRotation ()

Retrieves the rotation of the target intending to use images from this configuration.

This is one of four valid values: Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270. Rotation values are relative to the device's "natural" rotation, Surface.ROTATION_0.

Returns
int The stored value, if it exists in this configuration.

Throws
IllegalArgumentException if the option does not exist in this configuration.

getTargetRotation

public int getTargetRotation (int valueIfMissing)

Retrieves the rotation of the target intending to use images from this configuration.

This is one of four valid values: Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270. Rotation values are relative to the device's "natural" rotation, Surface.ROTATION_0.

Parameters
valueIfMissing int: The value to return if this configuration option has not been set.

Returns
int The stored value or valueIfMissing if the value does not exist in this configuration.