CameraSourceConfig.Builder
Stay organized with collections
Save and categorize content based on your preferences.
Builder for CameraSourceConfig.
Public Constructor Summary
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
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 Methods
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eCameraSourceConfig.Builder\u003c/code\u003e facilitates the creation and configuration of \u003ccode\u003eCameraSourceConfig\u003c/code\u003e instances for camera-based vision tasks.\u003c/p\u003e\n"],["\u003cp\u003eIt 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.\u003c/p\u003e\n"],["\u003cp\u003eThe builder pattern simplifies the configuration process and provides a clear way to set various parameters before building the final \u003ccode\u003eCameraSourceConfig\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers use \u003ccode\u003ebuild()\u003c/code\u003e to create an immutable \u003ccode\u003eCameraSourceConfig\u003c/code\u003e instance based on the builder's current configuration.\u003c/p\u003e\n"]]],["The `CameraSourceConfig.Builder` creates configurations for a camera source. It requires a context, a vision detector, and a detection task callback during construction. Key actions include setting the camera facing direction (front or back) via `setFacing`, specifying the desired camera frame dimensions using `setRequestedPreviewSize`, and finalizing the configuration with `build`. This builder allows customization of the camera source setup before creating the final `CameraSourceConfig`.\n"],null,["public static class **CameraSourceConfig.Builder** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nBuilder for CameraSourceConfig. \n\nPublic Constructor Summary\n\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| \\\u003cResultT\\\u003e | [Builder](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder#Builder(android.content.Context,%20com.google.mlkit.vision.interfaces.Detector\u003cResultT\u003e,%20com.google.mlkit.vision.camera.DetectionTaskCallback\u003cResultT\u003e))([Context](//developer.android.com/reference/android/content/Context.html) context, Detector\\\u003cResultT\\\u003e detector, [DetectionTaskCallback](/android/reference/com/google/mlkit/vision/camera/DetectionTaskCallback)\\\u003cResultT\\\u003e detectionTaskCallback) Creates a [CameraSourceConfig](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig) builder with the supplied context, a vision [Detector](/android/reference/com/google/mlkit/vision/interfaces/Detector) and a post detection [DetectionTaskCallback](/android/reference/com/google/mlkit/vision/camera/DetectionTaskCallback). |\n\nPublic Method Summary\n\n|------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [CameraSourceConfig](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig) | [build](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder#build())() |\n| [CameraSourceConfig.Builder](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder) | [setFacing](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder#setFacing(int))(int facing) Sets the camera to use (either [CameraSourceConfig.CAMERA_FACING_BACK](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig#CAMERA_FACING_BACK) or [CameraSourceConfig.CAMERA_FACING_FRONT](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig#CAMERA_FACING_FRONT)). |\n| [CameraSourceConfig.Builder](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder) | [setRequestedPreviewSize](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder#setRequestedPreviewSize(int,%20int))(int width, int height) Sets the desired width and height of the camera frames in pixels. |\n\nInherited Method Summary \nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors \n\npublic **Builder** ([Context](//developer.android.com/reference/android/content/Context.html) context, Detector\\\u003cResultT\\\u003e detector, [DetectionTaskCallback](/android/reference/com/google/mlkit/vision/camera/DetectionTaskCallback)\\\u003cResultT\\\u003e detectionTaskCallback) \nCreates a [CameraSourceConfig](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig)\nbuilder with the supplied context, a vision [Detector](/android/reference/com/google/mlkit/vision/interfaces/Detector)\nand a post detection [DetectionTaskCallback](/android/reference/com/google/mlkit/vision/camera/DetectionTaskCallback).\nCamera preview images will be streamed to the associated detector upon starting the\ncamera source.\n\nPublic Methods \n\npublic [CameraSourceConfig](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig)\n**build** () \n\npublic [CameraSourceConfig.Builder](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder)\n**setFacing** (int facing) \nSets the camera to use (either [CameraSourceConfig.CAMERA_FACING_BACK](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig#CAMERA_FACING_BACK) or [CameraSourceConfig.CAMERA_FACING_FRONT](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig#CAMERA_FACING_FRONT)). Default: [CameraSourceConfig.CAMERA_FACING_BACK](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig#CAMERA_FACING_BACK). \n\npublic [CameraSourceConfig.Builder](/android/reference/com/google/mlkit/vision/camera/CameraSourceConfig.Builder)\n**setRequestedPreviewSize** (int width, int height) \nSets the desired width and height of the camera frames in pixels. If the exact\ndesired values are not available options, the best matching available options are\nselected.\n\nWe pass the desired size to CameraX and let CameraX choose the best available\nsize.\n\nDefault: 480x360."]]