Builder for ObjectDetector.ObjectDetectorOptions
.
Public Constructors
Builder()
|
Public Methods
Inherited Methods
Public Constructors
public Builder ()
Public Methods
public final ObjectDetector.ObjectDetectorOptions build ()
Validates and builds the ObjectDetector.ObjectDetectorOptions
instance.
Throws
IllegalArgumentException | if the result listener and the running mode are not properly configured. The result listener should only be set when the object detector is in the live stream mode. |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setBaseOptions (BaseOptions value)
Sets the BaseOptions
for the object detector task.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setCategoryAllowlist (List<String> value)
Sets the optional allowlist of category names.
If non-empty, detection results whose category name is not in this set will be filtered
out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryDenylist
.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setCategoryDenylist (List<String> value)
Sets the optional denylist of category names.
If non-empty, detection results whose category name is in this set will be filtered out.
Duplicate or unknown category names are ignored. Mutually exclusive with categoryAllowlist
.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setDisplayNamesLocale (String value)
Sets the optional locale to use for display names specified through the TFLite Model Metadata, if any.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setErrorListener (ErrorListener value)
Sets an optional ErrorListener
}.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setMaxResults (Integer value)
Sets the optional maximum number of top-scored detection results to return.
Overrides the ones provided in the model metadata. Results below this value are rejected.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setResultListener (ResultListener<ObjectDetectorResult, MPImage> value)
Sets the OutputHandler.ResultListener
to receive the detection results asynchronously when the
object detector is in the live stream mode.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setRunningMode (RunningMode value)
Sets the RunningMode
for the object detector task. Default to the image mode.
Object detector has three modes:
- IMAGE: The mode for detecting objects on single image inputs.
- VIDEO: The mode for detecting objects on the decoded frames of a video.
- LIVE_STREAM: The mode for for detecting objects on a live stream of input data, such
as from camera. In this mode,
setResultListener
must be called to set up a listener to receive the detection results asynchronously.
Parameters
value |
---|
public abstract ObjectDetector.ObjectDetectorOptions.Builder setScoreThreshold (Float value)
Sets the optional score threshold that overrides the one provided in the model metadata (if any). Results below this value are rejected.
Parameters
value |
---|