Builder

class Builder : Builder<ImageAnalysisConfig.Builder!>, Builder<ImageAnalysisConfig.Builder!>, Builder<ImageAnalysisConfig.Builder!>, Builder<ImageAnalysis!, ImageAnalysisConfig!, ImageAnalysisConfig.Builder!>
kotlin.Any
   ↳ androidx.camera.core.ImageAnalysisConfig.Builder

Builder for a ImageAnalysisConfig.

Summary

Public constructors

Creates a new Builder object.

Public methods

ImageAnalysisConfig!

Builds an immutable ImageAnalysisConfig from the current state.

static ImageAnalysisConfig.Builder!

Generates a Builder from another Config object.

ImageAnalysisConfig.Builder
setBackgroundExecutor(@NonNull executor: Executor)

Sets the default executor that will be used for background tasks.

ImageAnalysisConfig.Builder!

Sets the default handler that will be used for callbacks.

ImageAnalysisConfig.Builder!

Sets the number of images available to the camera pipeline for ImageReaderMode#ACQUIRE_NEXT_IMAGE mode.

ImageAnalysisConfig.Builder!

Sets the mode that the image is acquired from ImageReader.

ImageAnalysisConfig.Builder
setLensFacing(@NonNull lensFacing: CameraX.LensFacing)

Sets the primary camera to be configured based on the direction the lens is facing.

ImageAnalysisConfig.Builder!

Sets the aspect ratio of the intended target for images from this configuration.

ImageAnalysisConfig.Builder!
setTargetName(targetName: String!)

Sets the name of the target object being configured.

ImageAnalysisConfig.Builder!
setTargetResolution(resolution: Size!)

Sets the resolution of the intended target from this configuration.

ImageAnalysisConfig.Builder!

Sets the rotation of the intended target for images from this configuration.

Public constructors

<init>

Builder()

Creates a new Builder object.

Public methods

build

fun build(): ImageAnalysisConfig!

Builds an immutable ImageAnalysisConfig from the current state.

Return
ImageAnalysisConfig!: A ImageAnalysisConfig populated with the current state.

fromConfig

static fun fromConfig(configuration: ImageAnalysisConfig!): ImageAnalysisConfig.Builder!

Generates a Builder from another Config object.

Parameters
configuration ImageAnalysisConfig!: An immutable configuration to pre-populate this builder.
Return
ImageAnalysisConfig.Builder!: The new Builder.

setBackgroundExecutor

@NonNull fun setBackgroundExecutor(@NonNull executor: Executor): ImageAnalysisConfig.Builder

Sets the default executor that will be used for background tasks.

Parameters
executor Executor: The executor which will be used for background tasks.
Return
ImageAnalysisConfig.Builder: the current Builder.

setCallbackHandler

fun setCallbackHandler(handler: Handler!): ImageAnalysisConfig.Builder!

Sets the default handler that will be used for callbacks.

Parameters
handler Handler!: The handler which will be used to post callbacks.
Return
ImageAnalysisConfig.Builder!: the current Builder.

setImageQueueDepth

fun setImageQueueDepth(depth: Int): ImageAnalysisConfig.Builder!

Sets the number of images available to the camera pipeline for ImageReaderMode#ACQUIRE_NEXT_IMAGE mode.

The image queue depth is the number of images available to the camera to fill with data. This includes the image currently being analyzed by . Increasing the image queue depth may make camera operation smoother, depending on the ImageReaderMode, at the cost of increased memory usage.

When the ImageReaderMode is set to , increasing the image queue depth will increase the amount of time available to analyze an image before stalling the capture pipeline.

When the ImageReaderMode is set to ImageReaderMode#ACQUIRE_NEXT_IMAGE, increasing the image queue depth may make the camera pipeline run smoother on systems under high load. However, the time spent analyzing an image should still be kept under a single frame period for the current frame rate, on average, to avoid stalling the camera pipeline.

The value only applys to ImageReaderMode#ACQUIRE_NEXT_IMAGE mode. For ImageReaderMode#ACQUIRE_LATEST_IMAGE the value is overridden by default value.

Parameters
depth Int: The total number of images available to the camera.
Return
ImageAnalysisConfig.Builder!: The current Builder.

setImageReaderMode

fun setImageReaderMode(mode: ImageAnalysis.ImageReaderMode!): ImageAnalysisConfig.Builder!

Sets the mode that the image is acquired from ImageReader.

The available values are ImageReaderMode#ACQUIRE_NEXT_IMAGE and .

Parameters
mode ImageAnalysis.ImageReaderMode!: The mode to set.
Return
ImageAnalysisConfig.Builder!: The current Builder.

setLensFacing

@NonNull fun setLensFacing(@NonNull lensFacing: CameraX.LensFacing): ImageAnalysisConfig.Builder

Sets the primary camera to be configured based on the direction the lens is facing.

If multiple cameras exist with equivalent lens facing direction, the first ("primary") camera for that direction will be chosen.

Parameters
lensFacing CameraX.LensFacing: The direction of the camera's lens.
Return
ImageAnalysisConfig.Builder: the current Builder.

setTargetAspectRatio

fun setTargetAspectRatio(aspectRatio: Rational!): ImageAnalysisConfig.Builder!

Sets the aspect ratio of the intended target for 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.

The target aspect ratio is used as a hint when determining the resulting output aspect ratio which may differ from the request, possibly due to device constraints. Application code should check the resulting output's resolution.

For ImageAnalysis, the output is the ImageProxy passed to the analyzer function.

Parameters
aspectRatio Rational!: A Rational representing the ratio of the target's width and height.
Return
ImageAnalysisConfig.Builder!: The current Builder.

setTargetName

fun setTargetName(targetName: String!): ImageAnalysisConfig.Builder!

Sets 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
targetName String!: A unique string identifier for the instance of the class being configured.
Return
ImageAnalysisConfig.Builder!: the current Builder.

setTargetResolution

fun setTargetResolution(resolution: Size!): ImageAnalysisConfig.Builder!

Sets the resolution of the intended target from this configuration.

The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.

Parameters
resolution Size!: The target resolution to choose from supported output sizes list.
Return
ImageAnalysisConfig.Builder!: The current Builder.

setTargetRotation

fun setTargetRotation(rotation: Int): ImageAnalysisConfig.Builder!

Sets the rotation of the intended target for images from this configuration.

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

Parameters
rotation Int: The rotation of the intended target.
Return
ImageAnalysisConfig.Builder!: The current Builder.