AI-generated Key Takeaways
-
The
Segmentation
class is used to identify foreground and background pixels in an image. -
To use it, you first create an
InputImage
from your image source (e.g., Bitmap). -
You then obtain a
Segmenter
instance usingSegmentation.getClient()
with desired options. -
Finally, you call
segmenter.process()
on theInputImage
to get aSegmentationMask
representing the segmentation result. -
Remember to close the
Segmenter
instance usingSegmenter.close()
when you are finished with it.
Entry point for identifying pixels in a supplied image as being part of the foreground or the background.
Segmenter segmenter = Segmentation.getClient(segmenterOptions);
To perform segmentation of an image, you first need to create an instance of
InputImage
from a Bitmap
,
ByteBuffer
, etc. See
InputImage
documentation for more details. For example, the code below creates an InputImage
from a Bitmap
.
InputImage image = InputImage.fromBitmap(bitmap, rotationDegrees);
InputImage
and
asynchronously return a SegmentationMask
.
Task<SegmentationMask> task = segmenter.process(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
Public Method Summary
static Segmenter |
getClient(SelfieSegmenterOptions
segmenterOptions)
Gets an instance of
Segmenter
that can segment the foreground and the background of an image.
|
Inherited Method Summary
Public Methods
public static Segmenter getClient (SelfieSegmenterOptions segmenterOptions)
Gets an instance of Segmenter
that can segment the foreground and the background of an image.
To release the resources associated with a Segmenter
,
you need to ensure that Segmenter.close()
is called on the resulting Segmenter
instance once it will no longer be used.