public final class

ImageCaptureConfig.Builder

extends java.lang.Object

implements UseCaseConfig.Builder<ImageCapture, ImageCaptureConfig, ImageCaptureConfig.Builder>, ImageOutputConfig.Builder<ImageCaptureConfig.Builder>, CameraDeviceConfig.Builder<ImageCaptureConfig.Builder>, androidx.camera.core.ThreadConfig.Builder<ImageCaptureConfig.Builder>

 java.lang.Object

↳androidx.camera.core.ImageCaptureConfig.Builder

Overview

Builder for a ImageCaptureConfig.

Summary

Constructors
publicBuilder()

Creates a new Builder object.

Methods
public ImageCaptureConfigbuild()

Builds an immutable ImageCaptureConfig from the current state.

public static ImageCaptureConfig.BuilderfromConfig(ImageCaptureConfig configuration)

Generates a Builder from another Config object

public MutableConfiggetMutableConfig()

public ImageCaptureConfig.BuildersetBackgroundExecutor(java.util.concurrent.Executor executor)

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

public ImageCaptureConfig.BuildersetBufferFormat(int bufferImageFormat)

Sets the of the ImageProxy returned by the .

public ImageCaptureConfig.BuildersetCameraIdFilter(CameraIdFilter cameraIdFilter)

Sets a CameraIdFilter that filter out the unavailable camera id.

public ImageCaptureConfig.BuildersetCaptureBundle(CaptureBundle captureBundle)

Sets the CaptureBundle.

public ImageCaptureConfig.BuildersetCaptureMode(ImageCapture.CaptureMode captureMode)

Sets the image capture mode.

public ImageCaptureConfig.BuildersetCaptureOptionUnpacker(CaptureConfig.OptionUnpacker optionUnpacker)

public ImageCaptureConfig.BuildersetCaptureProcessor(CaptureProcessor captureProcessor)

Sets the CaptureProcessor.

public ImageCaptureConfig.BuildersetDefaultCaptureConfig(CaptureConfig captureConfig)

public ImageCaptureConfig.BuildersetDefaultResolution(Size resolution)

Sets the default resolution of the intended target from this configuration.

public ImageCaptureConfig.BuildersetDefaultSessionConfig(SessionConfig sessionConfig)

public ImageCaptureConfig.BuildersetFlashMode(FlashMode flashMode)

Sets the FlashMode.

public ImageCaptureConfig.BuildersetLensFacing(androidx.camera.core.CameraX.LensFacing lensFacing)

Sets the primary camera to be configured based on the direction the lens is facing.

public ImageCaptureConfig.BuildersetMaxCaptureStages(int maxCaptureStages)

Sets the max number of CaptureStage.

public ImageCaptureConfig.BuildersetMaxResolution(Size resolution)

public ImageCaptureConfig.BuildersetSessionOptionUnpacker(SessionConfig.OptionUnpacker optionUnpacker)

public ImageCaptureConfig.BuildersetSupportedResolutions(java.util.List<> resolutions)

public ImageCaptureConfig.BuildersetSurfaceOccupancyPriority(int priority)

public ImageCaptureConfig.BuildersetTargetAspectRatio(AspectRatio aspectRatio)

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

public ImageCaptureConfig.BuildersetTargetAspectRatioCustom(Rational aspectRatio)

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

public ImageCaptureConfig.BuildersetTargetClass(java.lang.Class<ImageCapture> targetClass)

public ImageCaptureConfig.BuildersetTargetName(java.lang.String targetName)

Sets the name of the target object being configured.

public ImageCaptureConfig.BuildersetTargetResolution(Size resolution)

Sets the intended output target resolution.

public ImageCaptureConfig.BuildersetTargetRotation(int rotation)

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

public ImageCaptureConfig.BuildersetUseCaseEventListener(androidx.camera.core.UseCase.EventListener useCaseEventListener)

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

Constructors

public Builder()

Creates a new Builder object.

Methods

public static ImageCaptureConfig.Builder fromConfig(ImageCaptureConfig configuration)

Generates a Builder from another Config object

Parameters:

configuration: An immutable configuration to pre-populate this builder.

Returns:

The new Builder.

public MutableConfig getMutableConfig()

public ImageCaptureConfig build()

Builds an immutable ImageCaptureConfig from the current state.

Returns:

A ImageCaptureConfig populated with the current state.

public ImageCaptureConfig.Builder setCaptureMode(ImageCapture.CaptureMode captureMode)

Sets the image capture mode.

Valid capture modes are ImageCapture.CaptureMode, which prioritizes latency over image quality, or ImageCapture.CaptureMode, which prioritizes image quality over latency.

Parameters:

captureMode: The requested image capture mode.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setFlashMode(FlashMode flashMode)

Sets the FlashMode.

Parameters:

flashMode: The requested flash mode.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setCaptureBundle(CaptureBundle captureBundle)

Sets the CaptureBundle.

Parameters:

captureBundle: The requested capture bundle for extension.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setCaptureProcessor(CaptureProcessor captureProcessor)

Sets the CaptureProcessor.

Parameters:

captureProcessor: The requested capture processor for extension.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setBufferFormat(int bufferImageFormat)

Sets the of the ImageProxy returned by the .

Warning. This could lead to an invalid configuration as image format support is per device. Also, setting the buffer format in conjuncture with image capture extensions will result in an invalid configuration. In this case ImageCapture.ImageCapture(ImageCaptureConfig) will throw an java.lang.IllegalArgumentException.

Parameters:

bufferImageFormat: The image format for captured images.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setMaxCaptureStages(int maxCaptureStages)

Sets the max number of CaptureStage.

Parameters:

maxCaptureStages: The max CaptureStage number.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setSupportedResolutions(java.util.List<> resolutions)

public ImageCaptureConfig.Builder setTargetClass(java.lang.Class<ImageCapture> targetClass)

public ImageCaptureConfig.Builder setTargetName(java.lang.String targetName)

Sets the name of the target object being configured.

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

Parameters:

targetName: A unique string identifier for the instance of the class being configured.

Returns:

the current Builder.

public ImageCaptureConfig.Builder setLensFacing(androidx.camera.core.CameraX.LensFacing lensFacing)

Sets the primary camera to be configured based on the direction the lens is facing.

If multiple cameras exist with equivalent lens facing direction, the first ("primary") camera for that direction will be chosen.

Parameters:

lensFacing: The direction of the camera's lens.

Returns:

the current Builder.

public ImageCaptureConfig.Builder setCameraIdFilter(CameraIdFilter cameraIdFilter)

Sets a CameraIdFilter that filter out the unavailable camera id.

The camera id filter will be used to filter those cameras with lens facing specified in the config.

Parameters:

cameraIdFilter: The CameraIdFilter.

Returns:

the current Builder.

public ImageCaptureConfig.Builder setTargetAspectRatioCustom(Rational aspectRatio)

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

This is the ratio of the target's width to the image's height, where the numerator of the provided corresponds to the width, and the denominator corresponds to the height.

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.

This method can be used to request an aspect ratio that is not from the standard set of aspect ratios defined in the AspectRatio.

This method will remove any value set by setTargetAspectRatio().

For ImageCapture, the outputs are the ImageProxy or the File passed to image capture listeners.

Parameters:

aspectRatio: A representing the ratio of the target's width and height.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setTargetAspectRatio(AspectRatio aspectRatio)

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

It is not allowed to set both target aspect ratio and target resolution on the same use case.

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.

Parameters:

aspectRatio: A AspectRatio representing the ratio of the target's width and height.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setTargetRotation(int rotation)

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

This is one of four valid values: , , , . Rotation values are relative to the "natural" rotation, .

Parameters:

rotation: The rotation of the intended target.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setTargetResolution(Size resolution)

Sets the intended output target resolution.

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.

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio will also be set the same as the aspect ratio of the provided . Make sure to set the target resolution with the correct orientation.

Parameters:

resolution: The target resolution to choose from supported output sizes list.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setDefaultResolution(Size resolution)

Sets the default resolution of the intended target from this configuration.

Parameters:

resolution: The default resolution to choose from supported output sizes list.

Returns:

The current Builder.

public ImageCaptureConfig.Builder setMaxResolution(Size resolution)

public ImageCaptureConfig.Builder setBackgroundExecutor(java.util.concurrent.Executor executor)

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

Parameters:

executor: The executor which will be used for background tasks.

Returns:

the current Builder.

public ImageCaptureConfig.Builder setDefaultSessionConfig(SessionConfig sessionConfig)

public ImageCaptureConfig.Builder setDefaultCaptureConfig(CaptureConfig captureConfig)

public ImageCaptureConfig.Builder setSessionOptionUnpacker(SessionConfig.OptionUnpacker optionUnpacker)

public ImageCaptureConfig.Builder setCaptureOptionUnpacker(CaptureConfig.OptionUnpacker optionUnpacker)

public ImageCaptureConfig.Builder setSurfaceOccupancyPriority(int priority)

public ImageCaptureConfig.Builder setUseCaseEventListener(androidx.camera.core.UseCase.EventListener useCaseEventListener)