SubjectSegmenter
Stay organized with collections
Save and categorize content based on your preferences.
Inherited Method Summary
From interface java.io.Closeable
From interface java.lang.AutoCloseable
Public Methods
public abstract void close ()
Closes the segmenter and releases its resources.
public abstract Task<Void> getInitTask ()
Returns the task for initializing the
SubjectSegmenter
.
The initialization is triggered in the background when a
SubjectSegmenter
instance is created. The first
process(InputImage)
or
process(MlImage)
call will wait for the initialization to be finished.
If you want to optimize the latency of the first process call for better user
experience, you could call this method to track initialization progress and only make
the process call when the segmenter is successfully initialized.
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\u003eSubjectSegmenter\u003c/code\u003e is an interface used for generating subject segmentation results from images.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for processing images using either \u003ccode\u003eMlImage\u003c/code\u003e or \u003ccode\u003eInputImage\u003c/code\u003e to identify the main subject.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSubjectSegmenter\u003c/code\u003e can be closed to release resources, and its initialization can be tracked through \u003ccode\u003egetInitTask()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eprocess()\u003c/code\u003e methods return a \u003ccode\u003eTask\u003c/code\u003e containing the \u003ccode\u003eSubjectSegmentationResult\u003c/code\u003e, which represents the segmentation output.\u003c/p\u003e\n"]]],[],null,["# SubjectSegmenter\n\npublic interface **SubjectSegmenter** implements Detector\\\u003c[SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult)\\\u003e [OptionalModuleApi](/android/reference/com/google/android/gms/common/api/OptionalModuleApi) \nAn [SubjectSegmentation](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentation)\nclient for generating [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult) in a supplied image. \n\n### Public Method Summary\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [close](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter#close())() Closes the segmenter and releases its resources. |\n| abstract Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [getInitTask](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter#getInitTask())() Returns the task for initializing the [SubjectSegmenter](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter). |\n| abstract Task\\\u003c[SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult)\\\u003e | [process](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter#process(com.google.android.odml.image.MlImage))([MlImage](/android/reference/com/google/android/odml/image/MlImage) image) Generates [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult) from a supplied [MlImage](/android/reference/com/google/android/odml/image/MlImage). |\n| abstract Task\\\u003c[SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult)\\\u003e | [process](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter#process(com.google.mlkit.vision.common.InputImage))(InputImage image) Generates [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult) from a supplied [InputImage](/android/reference/com/google/mlkit/vision/common/InputImage). |\n\n### Inherited Method Summary\n\nFrom interface java.io.Closeable \n\n|---------------|---------|\n| abstract void | close() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Methods\n--------------\n\n#### public abstract void **close** ()\n\nCloses the segmenter and releases its resources. \n\n#### public abstract Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **getInitTask** ()\n\nReturns the task for initializing the [SubjectSegmenter](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter).\n\nThe initialization is triggered in the background when a [SubjectSegmenter](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter) instance is created. The first [process(InputImage)](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter#process(com.google.mlkit.vision.common.InputImage)) or [process(MlImage)](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmenter#process(com.google.android.odml.image.MlImage)) call will wait for the initialization to be finished.\n\nIf you want to optimize the latency of the first process call for better user\nexperience, you could call this method to track initialization progress and only make\nthe process call when the segmenter is successfully initialized. \n\n#### public abstract Task\\\u003c[SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult)\\\u003e\n**process** ([MlImage](/android/reference/com/google/android/odml/image/MlImage) image)\n\nGenerates [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult) from a supplied [MlImage](/android/reference/com/google/android/odml/image/MlImage).\n\nThis is an experimental API in beta version. \n\n##### Returns\n\n- a [Task](/android/reference/com/google/android/gms/tasks/Task) that asynchronously returns [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult). \n\n#### public abstract Task\\\u003c[SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult)\\\u003e\n**process** (InputImage image)\n\nGenerates [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult) from a supplied [InputImage](/android/reference/com/google/mlkit/vision/common/InputImage). \n\n##### Returns\n\n- a [Task](/android/reference/com/google/android/gms/tasks/Task) that asynchronously returns [SubjectSegmentationResult](/android/reference/com/google/mlkit/vision/segmentation/subject/SubjectSegmentationResult)."]]