AI-generated Key Takeaways
-
MLKImageLabeleris an object used for processing and labeling images. -
It can be initialized using
imageLabelerWithOptions:with specific configurations. -
Images can be processed asynchronously using
processImage:completion:or synchronously withresultsInImage:error:, although the latter is recommended to be done off the main thread. -
Results are provided as an array of
MLKImageLabelobjects, offering information about identified labels in the image.
MLKImageLabeler
@interface MLKImageLabeler : NSObjectAn image labeler that processes and labels images.
-
Returns an image labeler with the given options.
Declaration
Objective-C
+ (nonnull instancetype)imageLabelerWithOptions: (nonnull MLKCommonImageLabelerOptions *)options;Parameters
optionsOptions for configuring the image labeler.
Return Value
An image labeler configured with the given options.
-
Unavailable. Use the class methods.
Declaration
Objective-C
- (nonnull instancetype)init; -
Processes the given image for labeling.
Declaration
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKImageLabelingCallback)completion;Parameters
imageThe image to process.
completionHandler to call back on the main queue with labels or error.
-
Returns label results in the given image or
nilif there was an error. The image labeling 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
Objective-C
- (nullable NSArray<MLKImageLabel *> *) resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;Parameters
imageThe image to get results in.
errorAn optional error parameter populated when there is an error getting results.
Return Value
Array of label results in the given image or
nilif there was an error.