CameraSourceConfig.Builder

  • CameraSourceConfig.Builder is used to create configurations for a CameraSource.

  • A CameraSourceConfig builder requires a Context, a Detector, and a DetectionTaskCallback for creation.

  • The builder allows setting the camera facing direction (front or back) and the desired preview size.

  • The build() method is used to generate the final CameraSourceConfig object.

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.Builder
setRequestedPreviewSize (int width, int height)
Sets the desired width and height of the camera frames in pixels.

Inherited Method Summary

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

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.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年10月31日 UTC.