SelfieSegmenterOptions.Builder

  • SelfieSegmenterOptions.Builder is used to create SelfieSegmenterOptions objects for configuring selfie segmentation.

  • You can customize the segmentation process by enabling raw size masks, setting the detector mode (stream or single image), and providing a custom executor.

  • The build() method creates a SelfieSegmenterOptions instance based on the builder's settings.

  • By default, the detector mode is set to STREAM_MODE and an internal background thread pool is used if no custom executor is specified.

  • Enabling enableRawSizeMask() returns the segmentation mask in the model's output size, requiring you to handle rescaling if needed.

public static class SelfieSegmenterOptions.Builder extends Object

Builder for SelfieSegmenterOptions.

Public Constructor Summary

Public Method Summary

SelfieSegmenterOptions
SelfieSegmenterOptions.Builder
enableRawSizeMask()
Asks the segmenter to return the raw size mask which matches the model output size.
SelfieSegmenterOptions.Builder
SelfieSegmenterOptions.Builder
setExecutor(Executor executor)
Sets the custom Executor to use.

Inherited Method Summary

Public Constructors

public Builder ()

Public Methods

public SelfieSegmenterOptions build ()

public SelfieSegmenterOptions.Builder enableRawSizeMask ()

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.

public SelfieSegmenterOptions.Builder setDetectorMode (int detectorMode)

Sets the detector mode to be either SelfieSegmenterOptions.STREAM_MODE or SelfieSegmenterOptions.SINGLE_IMAGE_MODE.

By default, it is SelfieSegmenterOptions.STREAM_MODE.

For more details about use cases of each mode, please check the documentation of SelfieSegmenterOptions.STREAM_MODE and SelfieSegmenterOptions.SINGLE_IMAGE_MODE.

public SelfieSegmenterOptions.Builder setExecutor (Executor executor)

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.