CameraSourceConfig.Builder

  • CameraSourceConfig.Builder facilitates the creation and configuration of CameraSourceConfig instances for camera-based vision tasks.

  • It allows developers to specify the camera facing (front or back), desired preview size, and links a vision detector with a callback for processing detection results.

  • The builder pattern simplifies the configuration process and provides a clear way to set various parameters before building the final CameraSourceConfig object.

  • Developers use build() to create an immutable CameraSourceConfig instance based on the builder's current configuration.

public static class CameraSourceConfig.Builder extends Object

Builder for CameraSourceConfig.

Public Constructor Summary

<ResultT>
Builder(Context context, Detector<ResultT> detector, DetectionTaskCallback<ResultT> detectionTaskCallback)
Creates a CameraSourceConfig builder with the supplied context, a vision Detector and a post detection DetectionTaskCallback.

Public Method Summary

CameraSourceConfig
CameraSourceConfig.Builder
CameraSourceConfig.Builder
setRequestedPreviewSize(int width, int height)
Sets the desired width and height of the camera frames in pixels.

Inherited Method Summary

Public Constructors

public Builder (Context context, Detector<ResultT> detector, DetectionTaskCallback<ResultT> detectionTaskCallback)

Creates a CameraSourceConfig builder with the supplied context, a vision Detector and a post detection DetectionTaskCallback. Camera preview images will be streamed to the associated detector upon starting the camera source.

Public Methods

public CameraSourceConfig build ()

public CameraSourceConfig.Builder setRequestedPreviewSize (int width, int height)

Sets the desired width and height of the camera frames in pixels. If the exact desired values are not available options, the best matching available options are selected.

We pass the desired size to CameraX and let CameraX choose the best available size.

Default: 480x360.