public final class
ImageSegmenter
Performs image segmentation on images.
Note that, in addition to the standard segmentation API, ERROR(/segment)
and ERROR(/segmentForVideo)
, that take an input image and return the outputs, but involves deep copy of the
returns, ImageSegmenter also supports the callback API, ERROR(/segmentWithResultListener)
and
ERROR(/segmentForVideoWithResultListener)
, which allow you to access the outputs through zero
copy.
The callback API is available for all RunningMode
in ImageSegmenter. Set OutputHandler.ResultListener
in ImageSegmenter.ImageSegmenterOptions
properly to use the callback API.
The API expects a TFLite model with,TFLite Model Metadata..
- Input image
MPImage
- The image that image segmenter runs on.
- Output ImageSegmenterResult
ImageSegmenterResult
- An ImageSegmenterResult containing segmented masks.
Nested Classes
class | ImageSegmenter.ImageSegmenterOptions | Options for setting up an ImageSegmenter . |
|
class | ImageSegmenter.SegmentationOptions | Options for configuring runtime behavior of ImageSegmenter . |
Public Methods
static ImageSegmenter |
createFromOptions(Context context, ImageSegmenter.ImageSegmenterOptions segmenterOptions)
Creates an
ImageSegmenter instance from an ImageSegmenter.ImageSegmenterOptions . |
List<String> |
getLabels()
Get the category label list of the ImageSegmenter can recognize.
|
ImageSegmenterResult |
segment(MPImage image, ImageSegmenter.SegmentationOptions segmentationOptions)
Performs image segmentation on the provided single image.
|
ImageSegmenterResult |
segment(MPImage image, ImageProcessingOptions imageProcessingOptions)
Performs image segmentation on the provided single image.
|
ImageSegmenterResult | |
void |
segmentAsync(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Sends live image data to perform image segmentation, and the results will be available via the
OutputHandler.ResultListener provided in the ImageSegmenter.ImageSegmenterOptions . |
void |
segmentAsync(MPImage image, ImageSegmenter.SegmentationOptions segmentationOptions, long timestampMs)
Sends live image data to perform image segmentation, and the results will be available via the
OutputHandler.ResultListener provided in the ImageSegmenter.ImageSegmenterOptions . |
void |
segmentAsync(MPImage image, long timestampMs)
Sends live image data to perform image segmentation with default image processing options, i.e.
|
ImageSegmenterResult |
segmentForVideo(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Performs image segmentation on the provided video frame.
|
ImageSegmenterResult |
segmentForVideo(MPImage image, long timestampMs)
Performs image segmentation on the provided video frame with default image processing options,
i.e.
|
ImageSegmenterResult |
segmentForVideo(MPImage image, ImageSegmenter.SegmentationOptions segmentationOptions, long timestampMs)
Performs image segmentation on the provided video frame.
|
void |
segmentForVideoWithResultListener(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Performs image segmentation on the provided video frame, and provides zero-copied results via
OutputHandler.ResultListener in ImageSegmenter.ImageSegmenterOptions . |
void |
segmentForVideoWithResultListener(MPImage image, ImageSegmenter.SegmentationOptions segmentationOptions, long timestampMs)
Performs image segmentation on the provided video frame, and provides zero-copied results via
OutputHandler.ResultListener in ImageSegmenter.ImageSegmenterOptions . |
void |
segmentForVideoWithResultListener(MPImage image, long timestampMs)
Performs image segmentation on the provided video frame with default image processing options,
i.e.
|
void |
segmentWithResultListener(MPImage image, ImageProcessingOptions imageProcessingOptions)
Performs image segmentation on the provided single image, and provides zero-copied results via
OutputHandler.ResultListener in ImageSegmenter.ImageSegmenterOptions . |
void |
segmentWithResultListener(MPImage image)
Performs image segmentation on the provided single image with default image processing options,
i.e.
|
void |
segmentWithResultListener(MPImage image, ImageSegmenter.SegmentationOptions segmentationOptions)
Performs image segmentation on the provided single image, and provides zero-copied results via
OutputHandler.ResultListener in ImageSegmenter.ImageSegmenterOptions . |