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 | |
---|---|
<init>() Creates a new Builder object. |
Public methods | |
---|---|
ImageAnalysis |
build() Builds an |
ImageAnalysis.Builder |
setBackgroundExecutor(@NonNull executor: Executor) Sets the default executor that will be used for background tasks. |
ImageAnalysis.Builder |
setBackpressureStrategy(strategy: Int) 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 |
setImageQueueDepth(depth: Int) Sets the number of images available to the camera pipeline for |
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 |
setTargetRotation(rotation: Int) 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 configure |