ResolutionStrategy


public final class ResolutionStrategy


The resolution strategy defines the resolution selection sequence to select the best size.

Applications can create a ResolutionSelector with a proper ResolutionStrategy to choose the preferred resolution.

Summary

Constants

static final int

When the specified bound size is unavailable, CameraX falls back to the closest higher resolution size.

static final int

When the specified bound size is unavailable, CameraX falls back to select the closest higher resolution size.

static final int

When the specified bound size is unavailable, CameraX falls back to the closest lower resolution size.

static final int

When the specified bound size is unavailable, CameraX falls back to select the closest lower resolution size.

static final int

CameraX doesn't select an alternate size when the specified bound size is unavailable.

static final @NonNull ResolutionStrategy

A resolution strategy chooses the highest available resolution.

Public constructors

ResolutionStrategy(@NonNull Size boundSize, int fallbackRule)

Creates a new ResolutionStrategy instance, configured with the specified bound size and fallback rule.

Public methods

@Nullable Size

Returns the specified bound size.

int

Returns the fallback rule for choosing an alternate size when the specified bound size is unavailable.

Constants

FALLBACK_RULE_CLOSEST_HIGHER

Added in 1.3.0
public static final int FALLBACK_RULE_CLOSEST_HIGHER = 2

When the specified bound size is unavailable, CameraX falls back to the closest higher resolution size.

FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER

Added in 1.3.0
public static final int FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER = 1

When the specified bound size is unavailable, CameraX falls back to select the closest higher resolution size. If CameraX still cannot find any available resolution, it will fallback to select other lower resolutions.

FALLBACK_RULE_CLOSEST_LOWER

Added in 1.3.0
public static final int FALLBACK_RULE_CLOSEST_LOWER = 4

When the specified bound size is unavailable, CameraX falls back to the closest lower resolution size.

FALLBACK_RULE_CLOSEST_LOWER_THEN_HIGHER

Added in 1.3.0
public static final int FALLBACK_RULE_CLOSEST_LOWER_THEN_HIGHER = 3

When the specified bound size is unavailable, CameraX falls back to select the closest lower resolution size. If CameraX still cannot find any available resolution, it will fallback to select other higher resolutions.

FALLBACK_RULE_NONE

Added in 1.3.0
public static final int FALLBACK_RULE_NONE = 0

CameraX doesn't select an alternate size when the specified bound size is unavailable.

Applications will receive IllegalArgumentException when binding the UseCases with this fallback rule if the device doesn't support the specified bound size.

HIGHEST_AVAILABLE_STRATEGY

Added in 1.3.0
public static final @NonNull ResolutionStrategy HIGHEST_AVAILABLE_STRATEGY

A resolution strategy chooses the highest available resolution. This strategy does not have a bound size or fallback rule. When using this strategy, CameraX selects the available resolutions to use in descending order, starting with the highest quality resolution available.

Public constructors

ResolutionStrategy

Added in 1.3.0
public ResolutionStrategy(@NonNull Size boundSize, int fallbackRule)

Creates a new ResolutionStrategy instance, configured with the specified bound size and fallback rule.

If the resolution candidate list contains the bound size and the bound size can fulfill all resolution selector settings, CameraX can also select the specified bound size as the result for the UseCase.

Some devices may have issues using sizes of the preferred aspect ratios. CameraX recommends that applications use the following fallback rule setting to avoid no resolution being available, as an IllegalArgumentException may be thrown when calling bindToLifecycle to bind UseCases with the ResolutionStrategy specified in the ResolutionSelector.

Parameters
@NonNull Size boundSize

the bound size to select the best resolution with the fallback rule.

int fallbackRule

the rule to follow when the specified bound size is not available.

Public methods

getBoundSize

Added in 1.3.0
public @Nullable Size getBoundSize()

Returns the specified bound size.

Returns
@Nullable Size

the specified bound size or null if this is instance of HIGHEST_AVAILABLE_STRATEGY.

getFallbackRule

Added in 1.3.0
public int getFallbackRule()

Returns the fallback rule for choosing an alternate size when the specified bound size is unavailable.