Segmentation

public class Segmentation extends Object

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);
Then the code below can segment the supplied 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.