Segmentation

  • The Segmentation class is the entry point for identifying foreground and background pixels in an image.

  • To perform segmentation, you first create an InputImage from a source like a Bitmap or ByteBuffer.

  • You then get a Segmenter instance using getClient with appropriate options.

  • The Segmenter processes the InputImage asynchronously and returns a SegmentationMask.

  • Remember to call Segmenter.close() when you are done with the Segmenter instance to release resources.

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.

Design a Mobile Site
View Site in Mobile | Classic
Share by: