Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

Builder

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

Builder for a ImageAnalysis.

Summary

Public constructors

Creates a new Builder object.

Public methods
ImageAnalysis

Builds an ImageAnalysis from the current state.

ImageAnalysis.Builder
setBackgroundExecutor(@NonNull executor: Executor)

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

ImageAnalysis.Builder

Sets the backpressure strategy to apply to the image producer to deal with scenarios where images may be produced faster than they can be analyzed.

ImageAnalysis.Builder

Sets the number of images available to the camera pipeline for STRATEGY_BLOCK_PRODUCER mode.

ImageAnalysis.Builder
setTargetAspectRatio(aspectRatio: Int)

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

ImageAnalysis.Builder
setTargetName(@NonNull targetName: String)

Sets the name of the target object being configured, used only for debug logging.

ImageAnalysis.Builder
setTargetResolution(@NonNull resolution: Size)

Sets the resolution of the intended target from this configuration.

ImageAnalysis.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

@NonNull fun build(): ImageAnalysis

Builds an ImageAnalysis from the current state.

Return
ImageAnalysis A ImageAnalysis populated with the current state.
Exceptions
IllegalArgumentException if attempting to set both target aspect ratio and target resolution.

setBackgroundExecutor

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

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

If not set, the background executor will default to an automatically generated Executor.

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

setBackpressureStrategy

@NonNull fun setBackpressureStrategy(strategy: Int): ImageAnalysis.Builder

Sets the backpressure strategy to apply to the image producer to deal with scenarios where images may be produced faster than they can be analyzed.

The available values are STRATEGY_BLOCK_PRODUCER and STRATEGY_KEEP_ONLY_LATEST.

If not set, the backpressure strategy will default to STRATEGY_KEEP_ONLY_LATEST.

Parameters
strategy Int: The strategy to use.
Return
ImageAnalysis.Builder The current Builder.

setImageQueueDepth

@NonNull fun setImageQueueDepth(depth: Int): ImageAnalysis.Builder

Sets the number of images available to the camera pipeline for STRATEGY_BLOCK_PRODUCER 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 backpressure strategy, at the cost of increased memory usage.

When the backpressure strategy is set to STRATEGY_BLOCK_PRODUCER, 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 applies to STRATEGY_BLOCK_PRODUCER mode. For STRATEGY_KEEP_ONLY_LATEST the value is ignored.

If not set, and this option is used by the selected backpressure strategy, the default will be a queue depth of 6 images.

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

setTargetAspectRatio

@NonNull fun setTargetAspectRatio(aspectRatio: Int): ImageAnalysis.Builder

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

The aspect ratio is the ratio of width to height in the sensor orientation.

It is not allowed to set both target aspect ratio and target resolution on the same use case. Attempting so will throw an IllegalArgumentException when building the Config.

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 and the resulting aspect ratio may not be exactly as requested.

If not set, resolutions with aspect ratio 4:3 will be considered in higher priority.

Parameters
aspectRatio Int: The desired ImageAnalysis AspectRatio
Return
ImageAnalysis.Builder The current Builder.

setTargetName

@NonNull fun setTargetName(@NonNull targetName: String): ImageAnalysis.Builder

Sets the name of the target object being configured, used only for debug logging.

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

If not set, the target name will default to a unique name automatically generated with the class canonical name and random UUID.

Parameters
targetName String: A unique string identifier for the instance of the class being configured.
Return
ImageAnalysis.Builder the current Builder.

setTargetResolution

@NonNull fun setTargetResolution(@NonNull resolution: Size): ImageAnalysis.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. Resolutions with the same aspect ratio of the provided Size will be considered in higher priority before resolutions of different aspect ratios.

It is not allowed to set both target aspect ratio and target resolution on the same use case. Attempting so will throw an IllegalArgumentException when building the Config.

The resolution Size should be expressed in the coordinate frame after rotating the supported sizes by the target rotation. For example, a device with portrait natural orientation in natural target rotation requesting a portrait image may specify 480x640, and the same device, rotated 90 degrees and targeting landscape orientation may specify 640x480.

The maximum available resolution that could be selected for an ImageAnalysis is limited to be under 1080p. The limitation of 1080p for ImageAnalysis has considered both performance and quality factors so that users can obtain reasonable quality and smooth output stream under 1080p.

If not set, resolution of 640x480 will be selected to use in priority.

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

setTargetRotation

@NonNull fun setTargetRotation(rotation: Int): ImageAnalysis.Builder

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

This adjust the ImageInfo#getRotationDegrees() of the ImageProxy passed to Analyzer#analyze(ImageProxy). The rotation value of ImageInfo will be the rotation, which if applied to the output image, will make the image match target rotation specified here.

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.

In general, it is best to additionally set the target rotation dynamically on the use case. See androidx.camera.core.ImageAnalysis#setTargetRotation(int) for additional documentation.

If not set, the target rotation will default to the value of android.view.Display#getRotation() of the default display at the time the use case is created. The use case is fully created once it has been attached to a camera.

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