ImageSegmenter
class ImageSegmenter : NSObject@brief Class that performs segmentation on images.
The API expects a TFLite model with mandatory TFLite Model Metadata.
- 
                  
                  Get the category label list of the ImageSegmentercan recognize. For CATEGORY_MASK type, the index in the category mask corresponds to the category in the label list. For CONFIDENCE_MASK type, the output mask list at index corresponds to the category in the label list. If there is no labelmap provided in the model file, empty array is returned.DeclarationSwift var labels: [String] { get }
- 
                  
                  Creates a new instance of ImageSegmenterfrom an absolute path to a TensorFlow Lite model file stored locally on the device and the defaultImageSegmenterOptions.DeclarationSwift convenience init(modelPath: String) throwsParametersmodelPathAn absolute path to a TensorFlow Lite model file stored locally on the device. Return ValueA new instance of ImageSegmenterwith the given model path.nilif there is an error in initializing the image segmenter.
- 
                  
                  Creates a new instance of ImageSegmenterfrom the givenImageSegmenterOptions.DeclarationSwift init(options: ImageSegmenterOptions) throwsParametersoptionsThe options of type ImageSegmenterOptionsto use for configuring theImageSegmenter.Return ValueA new instance of ImageSegmenterwith the given options.nilif there is an error in initializing the image segmenter.
- 
                  
                  Performs segmentation on the provided MPPImage using the whole image as region of interest. Rotation will be applied according to the orientationproperty of the providedMPImage. Only use this method when theImageSegmenteris created with running mode,image.This method supports segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If your MPImagehas a source type of.imageensure that the color space is RGB with an Alpha channel.DeclarationSwift func segment(image: MPImage) throws -> ImageSegmenterResultParametersimageThe MPImageon which segmentation is to be performed.Return ValueAn ImageSegmenterResultthat contains the segmented masks.
- 
                  
                  Performs segmentation on the provided MPPImage using the whole image as region of interest and invokes the given completion handler block with the response. The method returns synchronously once the completion handler returns. Rotation will be applied according to the orientationproperty of the providedMPImage. Only use this method when theImageSegmenteris created with running mode,image.This method supports segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If your MPImagehas a source type ofimageensure that the color space is RGB with an Alpha channel.DeclarationSwift func segment(image: MPImage) async throws -> ImageSegmenterResultParametersimageThe MPImageon which segmentation is to be performed.completionHandlerA block to be invoked with the results of performing segmentation on the image. The block takes two arguments, the optional ImageSegmenterResultthat contains the segmented masks if the segmentation was successful and an optional error populated upon failure. The lifetime of the returned masks is only guaranteed for the duration of the block.
- 
                  
                  Performs segmentation on the provided video frame of type MPImageusing the whole image as region of interest.Rotation will be applied according to the orientationproperty of the providedMPImage. Only use this method when theImageSegmenteris created withvideo.This method supports segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If your MPImagehas a source type ofimageensure that the color space is RGB with an Alpha channel.DeclarationSwift func segment(videoFrame image: MPImage, timestampInMilliseconds: Int) throws -> ImageSegmenterResultParametersimageThe MPImageon which segmentation is to be performed.timestampInMillisecondsThe video frame’s timestamp (in milliseconds). The input timestamps must be monotonically increasing. Return ValueAn ImageSegmenterResultthat contains a the segmented masks.
- 
                  
                  Performs segmentation on the provided video frame of type MPImageusing the whole image as region of interest invokes the given completion handler block with the response. The method returns synchronously once the completion handler returns.Rotation will be applied according to the orientationproperty of the providedMPImage. Only use this method when theImageSegmenteris created with running mode,video.This method supports segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If your MPImagehas a source type ofimageensure that the color space is RGB with an Alpha channel.DeclarationSwift func segment(videoFrame image: MPImage, timestampInMilliseconds: Int) async throws -> ImageSegmenterResultParametersimageThe MPImageon which segmentation is to be performed.timestampInMillisecondsThe video frame’s timestamp (in milliseconds). The input timestamps must be monotonically increasing. completionHandlerA block to be invoked with the results of performing segmentation on the image. The block takes two arguments, the optional ImageSegmenterResultthat contains the segmented masks if the segmentation was successful and an optional error only populated upon failure. The lifetime of the returned masks is only guaranteed for the duration of the block.
- 
                  
                  Sends live stream image data of type MPImageto perform segmentation using the whole image as region of interest.Rotation will be applied according to the orientationproperty of the providedMPImage. Only use this method when theImageSegmenteris created with running mode,liveStream.The object which needs to be continuously notified of the available results of image segmentation must confirm to ImageSegmenterLiveStreamDelegateprotocol and implement theimageSegmenter(_:didFinishSegmentationWithResult:timestampInMilliseconds:error:)delegate method.It’s required to provide a timestamp (in milliseconds) to indicate when the input image is sent to the segmenter. The input timestamps must be monotonically increasing. This method supports segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If the input MPImagehas a source type ofimageensure that the color space is RGB with an Alpha channel.If this method is used for classifying live camera frames using AVFoundation, ensure that you requestAVCaptureVideoDataOutputto output frames inkCMPixelFormat_32BGRAusing itsvideoSettingsproperty.DeclarationSwift func segmentAsync(image: MPImage, timestampInMilliseconds: Int) throwsParametersimageA live stream image data of type MPImageon which segmentation is to be performed.timestampInMillisecondsThe timestamp (in milliseconds) which indicates when the input image is sent to the segmenter. The input timestamps must be monotonically increasing. Return ValueYESif the image was sent to the task successfully, otherwiseNO.
- 
                  
                  Undocumented 
- 
                  
                  Undocumented