ImageSegmenter
final class ImageSegmenterSegments images, video frames, or live camera streams with a TFLite model that has metadata (region-of-interest is unsupported).
-
Creates an image segmenter in
.imagemode from a local model file path.Declaration
Swift
convenience init(modelPath: String) throws -
Creates an image segmenter and initializes the underlying MediaPipe task graph.
Declaration
Swift
init(options: ImageSegmenterOptions) throws -
Category labels from the model metadata, indexed by category mask value and confidence mask position, or empty if the model has no label map.
Declaration
Swift
final let labels: [String] -
Segments a single image in
.imagerunning mode.Declaration
Swift
final func segment(image: MPImage, imageProcessingOptions: ImageProcessingOptions? = nil) throws -> ImageSegmenterResult -
Segments a decoded video frame at monotonically increasing
timestampInMillisecondsin.videorunning mode.Declaration
Swift
final func segment(videoFrame: MPImage, timestampInMilliseconds: Int, imageProcessingOptions: ImageProcessingOptions? = nil) throws -> ImageSegmenterResult -
Sends a live-stream frame at monotonically increasing
timestampInMillisecondsfor asynchronous segmentation in.liveStreamrunning mode.Results are delivered to
ImageSegmenterOptions.liveStreamResultHandler.Declaration
Swift
final func segmentAsync(image: MPImage, timestampInMilliseconds: Int, imageProcessingOptions: ImageProcessingOptions? = nil) throws