SelfieSegmenterOptions.Builder
Stay organized with collections
Save and categorize content based on your preferences.
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
Asks the segmenter to return the raw size mask which matches the model output
size.
The raw mask size (e.g. 256x256) is usually smaller than the InputImage
size. Please call
SegmentationMask.getWidth()
and
SegmentationMask.getHeight()
to get the size when enabling this option.
Without specifying this option, the segmenter will rescale the raw mask to match the
input image size. Consider using this option if you want to apply customized rescaling
logic or rescaling is not needed for your use case.
Sets the custom Executor
to use. If no Executor
is set, an internal background thread pool will be used.
Most clients should not need to call this method.
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.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eSelfieSegmenterOptions.Builder\u003c/code\u003e is used to create \u003ccode\u003eSelfieSegmenterOptions\u003c/code\u003e objects for configuring selfie segmentation.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the segmentation process by enabling raw size masks, setting the detector mode (stream or single image), and providing a custom executor.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild()\u003c/code\u003e method creates a \u003ccode\u003eSelfieSegmenterOptions\u003c/code\u003e instance based on the builder's settings.\u003c/p\u003e\n"],["\u003cp\u003eBy default, the detector mode is set to \u003ccode\u003eSTREAM_MODE\u003c/code\u003e and an internal background thread pool is used if no custom executor is specified.\u003c/p\u003e\n"],["\u003cp\u003eEnabling \u003ccode\u003eenableRawSizeMask()\u003c/code\u003e returns the segmentation mask in the model's output size, requiring you to handle rescaling if needed.\u003c/p\u003e\n"]]],["The `SelfieSegmenterOptions.Builder` class facilitates the creation of `SelfieSegmenterOptions`. Key actions include: calling the `Builder` constructor, setting the detector mode to `STREAM_MODE` or `SINGLE_IMAGE_MODE` using `setDetectorMode`, enabling raw size mask output with `enableRawSizeMask` which will return the raw size mask, and assigning a custom `Executor` via `setExecutor`. Finally, the `build` method generates the configured `SelfieSegmenterOptions`.\n"],null,["# SelfieSegmenterOptions.Builder\n\npublic static class **SelfieSegmenterOptions.Builder** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nBuilder for [SelfieSegmenterOptions](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions). \n\n### Public Constructor Summary\n\n|---|----------------------------------------------------------------------------------------------------------------------|\n| | [Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder#Builder())() |\n\n### Public Method Summary\n\n|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SelfieSegmenterOptions](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions) | [build](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder#build())() |\n| [SelfieSegmenterOptions.Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder) | [enableRawSizeMask](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder#enableRawSizeMask())() Asks the segmenter to return the raw size mask which matches the model output size. |\n| [SelfieSegmenterOptions.Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder) | [setDetectorMode](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder#setDetectorMode(int))(int detectorMode) Sets the detector mode to be either [SelfieSegmenterOptions.STREAM_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#STREAM_MODE) or [SelfieSegmenterOptions.SINGLE_IMAGE_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#SINGLE_IMAGE_MODE). |\n| [SelfieSegmenterOptions.Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder) | [setExecutor](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder#setExecutor(java.util.concurrent.Executor))([Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) executor) Sets the custom [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) to use. |\n\n### Inherited Method Summary\n\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-------------------\n\n#### public **Builder** ()\n\nPublic Methods\n--------------\n\n#### public [SelfieSegmenterOptions](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions) **build**\n()\n\n#### public [SelfieSegmenterOptions.Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder) **enableRawSizeMask** ()\n\nAsks the segmenter to return the raw size mask which matches the model output\nsize.\n\nThe raw mask size (e.g. 256x256) is usually smaller than the [InputImage](/android/reference/com/google/mlkit/vision/common/InputImage)\nsize. Please call [SegmentationMask.getWidth()](/android/reference/com/google/mlkit/vision/segmentation/SegmentationMask#getWidth()) and [SegmentationMask.getHeight()](/android/reference/com/google/mlkit/vision/segmentation/SegmentationMask#getHeight()) to get the size when enabling this option.\n\nWithout specifying this option, the segmenter will rescale the raw mask to match the\ninput image size. Consider using this option if you want to apply customized rescaling\nlogic or rescaling is not needed for your use case. \n\n#### public [SelfieSegmenterOptions.Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder) **setDetectorMode** (int detectorMode)\n\nSets the detector mode to be either [SelfieSegmenterOptions.STREAM_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#STREAM_MODE) or [SelfieSegmenterOptions.SINGLE_IMAGE_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#SINGLE_IMAGE_MODE).\n\nBy default, it is [SelfieSegmenterOptions.STREAM_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#STREAM_MODE).\n\nFor more details about use cases of each mode, please check the documentation of\n[SelfieSegmenterOptions.STREAM_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#STREAM_MODE) and [SelfieSegmenterOptions.SINGLE_IMAGE_MODE](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions#SINGLE_IMAGE_MODE). \n\n#### public [SelfieSegmenterOptions.Builder](/android/reference/com/google/mlkit/vision/segmentation/selfie/SelfieSegmenterOptions.Builder) **setExecutor** ([Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) executor)\n\nSets the custom [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html)\nto use. If no [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html)\nis set, an internal background thread pool will be used.\n\nMost clients should not need to call this method."]]