public final class

ResolutionSelector.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.camera.core.resolutionselector.ResolutionSelector.Builder

Overview

Builder for a ResolutionSelector.

Summary

Constructors
publicBuilder()

Creates a Builder instance.

Methods
public ResolutionSelectorbuild()

Builds the resolution selector.

public static ResolutionSelector.BuilderfromResolutionSelector(ResolutionSelector resolutionSelector)

Creates a Builder from an existing resolution selector.

public ResolutionSelector.BuildersetAllowedResolutionMode(int mode)

Sets the allowed resolution mode.

public ResolutionSelector.BuildersetAspectRatioStrategy(AspectRatioStrategy aspectRatioStrategy)

Sets the aspect ratio selection strategy for the UseCase.

public ResolutionSelector.BuildersetResolutionFilter(ResolutionFilter resolutionFilter)

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

public ResolutionSelector.BuildersetResolutionStrategy(ResolutionStrategy resolutionStrategy)

Sets the resolution selection strategy for the UseCase.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a Builder instance.

Methods

public static ResolutionSelector.Builder fromResolutionSelector(ResolutionSelector resolutionSelector)

Creates a Builder from an existing resolution selector.

public ResolutionSelector.Builder setAspectRatioStrategy(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, AspectRatioStrategy.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 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.

public ResolutionSelector.Builder setResolutionStrategy(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 AspectRatioStrategy.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 AspectRatioStrategy.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.

public ResolutionSelector.Builder setResolutionFilter(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.

public ResolutionSelector.Builder setAllowedResolutionMode(int mode)

Sets the allowed resolution mode.

If not specified, the default setting is ResolutionSelector.PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION.

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