ResolutionSelector.Builder


public final class ResolutionSelector.Builder


Builder for a ResolutionSelector.

Summary

Public constructors

Creates a Builder instance.

Public methods

@NonNull ResolutionSelector

Builds the resolution selector.

@NonNull ResolutionSelector.Builder

Sets the allowed resolution mode.

@NonNull ResolutionSelector.Builder

Sets the aspect ratio selection strategy for the UseCase.

@NonNull ResolutionSelector.Builder

Sets the resolution filter to output the final desired sizes list.

@NonNull ResolutionSelector.Builder

Sets the resolution selection strategy for the UseCase.

Public constructors

Builder

Added in 1.3.0
public Builder()

Creates a Builder instance.

Public methods

build

Added in 1.3.0
public @NonNull ResolutionSelector build()

Builds the resolution selector. This will create a resolution selector that can be used to select the desired resolution for the captured image.

setAllowedResolutionMode

Added in 1.3.0
public @NonNull ResolutionSelector.Builder setAllowedResolutionMode(int mode)

Sets the allowed resolution mode.

If not specified, the default setting is PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION.

setAspectRatioStrategy

Added in 1.3.0
public @NonNull ResolutionSelector.Builder setAspectRatioStrategy(@NonNull AspectRatioStrategy aspectRatioStrategy)

Sets the aspect ratio selection strategy for the UseCase. The aspect ratio selection strategy determines how the UseCase will choose the aspect ratio of the captured image.

If the aspect ratio strategy is not specified, RATIO_4_3_FALLBACK_AUTO_STRATEGY will be used as the default.

UseCases can be bound by a UseCaseGroup with a ViewPort setting. If a ViewPort is set, it is recommended that the ViewPort and the bound UseCases should have matching aspect ratio settings. Otherwise, the output crop rectangles may be double-cropped from the full camera sensor field of view. See ViewPort.Builder for details.

CameraX only supports the common 4:3 and 16:9 aspect ratio settings. Some devices may offer additional output sizes. To access these, you'll need to create a ResolutionSelector with a ResolutionFilter to find and select those specific sizes.

setResolutionFilter

Added in 1.3.0
public @NonNull ResolutionSelector.Builder setResolutionFilter(@NonNull ResolutionFilter resolutionFilter)

Sets the resolution filter to output the final desired sizes list. The resolution filter will filter out unsuitable sizes and sort the resolution list in the preferred order. The preferred order is the order in which the resolutions should be tried first.

setResolutionStrategy

Added in 1.3.0
public @NonNull ResolutionSelector.Builder setResolutionStrategy(@NonNull ResolutionStrategy resolutionStrategy)

Sets the resolution selection strategy for the UseCase. The resolution selection strategy determines how the UseCase will choose the resolution of the captured image.

Note: ResolutionStrategy works in conjunction with AspectRatioStrategy and the default AspectRatioStrategy is RATIO_4_3_FALLBACK_AUTO_STRATEGY. Ensure you set a corresponding AspectRatioStrategy alongside your ResolutionStrategy. For example, if your ResolutionStrategy uses a bound size of 1920x1080 and a 16:9 aspect ratio is preferred, set RATIO_16_9_FALLBACK_AUTO_STRATEGY when building the ResolutionSelector.

CameraX only supports the common 4:3 and 16:9 aspect ratio settings. To select resolution of other aspect ratios, you'll need to create a ResolutionSelector with a ResolutionFilter to find and select those specific sizes.