AI-generated Key Takeaways
-
The
Segmenterclass performs segmentation on input images to identify different regions or objects. -
It provides methods for asynchronous and synchronous processing of images for segmentation.
-
You can configure the segmenter using
MLKCommonSegmenterOptionswhen initializing. -
Results are provided as an
MLKSegmentationMaskobject which can be used to understand the identified segments. -
Direct instantiation with
initis unavailable; use the provided class methods likesegmenter(options:)instead.
Segmenter
class Segmenter : NSObjectA detector that performs segmentation on input images.
-
Returns a segmenter with the given options.
Declaration
Swift
class func segmenter(options: MLKCommonSegmenterOptions) -> SelfParameters
optionsOptions for configuring the segmenter.
Return Value
A segmenter configured with the given options.
-
Unavailable. Use the class methods.
-
Processes the given image for segmentation.
Declaration
Swift
func process(_ image: MLKitCompatibleImage) async throws -> MLKSegmentationMaskParameters
imageThe image to process.
completionHandler to call back on the main thread with the segmentation mask or error.
-
Returns the segmentation mask in the given image or
nilif there was an error. The segmentation is performed synchronously on the calling thread.It is advised to call this method off the main thread to avoid blocking the UI. As a result, an
NSExceptionis raised if this method is called on the main thread.Declaration
Swift
func results(in image: MLKitCompatibleImage) throws -> MLKSegmentationMaskParameters
imageThe image to get results in.
errorAn optional error parameter populated when there is an error getting results.
Return Value
The segmentation mask in the given image or
nilif there was an error.