AI-generated Key Takeaways
-
MLKObjectDetectoris an object detector and tracker for identifying and following objects within images. -
It provides methods for synchronous and asynchronous processing of images to detect objects.
-
Users can configure the detector with options via
objectDetectorWithOptions:. -
Results can be retrieved using completion handlers or synchronously using
resultsInImage:error:, which should be called off the main thread to avoid UI blocking.
MLKObjectDetector
@interface MLKObjectDetector : NSObjectAn object detector and tracker that detects objects in an image and supports tracking them.
-
Returns an object detector with the given options.
Declaration
Objective-C
+ (nonnull instancetype)objectDetectorWithOptions: (nonnull MLKCommonObjectDetectorOptions *)options;Parameters
optionsOptions for configuring the object detector. It should be an instance of one of
CommonObjectDetectorOptions‘s subclasses.Return Value
An object detector configured with the given options.
-
Unavailable. Use the class methods.
Declaration
Objective-C
- (nonnull instancetype)init; -
Processes the given image for object detection and tracking.
Declaration
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKObjectDetectionCallback)completion;Parameters
imageThe image to process.
completionHandler to call back on the main thread with objects detected or error.
-
Returns object results in the given image or
nilif there was an error. The object detection 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<MLKObject *> *) 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 object results in the given image or
nilif there was an error.