MLKitObjectDetectionCommon Framework Reference

ObjectDetector

class ObjectDetector : NSObject

An object detector and tracker that detects objects in an image and supports tracking them.

  • Returns an object detector with the given options.

    Declaration

    Swift

    class func objectDetector(options: MLKCommonObjectDetectorOptions) -> Self

    Parameters

    options

    Options 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.

  • Processes the given image for object detection and tracking.

    Declaration

    Swift

    func process(_ image: MLKitCompatibleImage, completion: @escaping ObjectDetectionCallback)

    Parameters

    image

    The image to process.

    completion

    Handler to call back on the main thread with objects detected or error.

  • Returns object results in the given image or nil if 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 NSException is raised if this method is called on the main thread.

    Declaration

    Swift

    func results(in image: MLKitCompatibleImage) throws -> [MLKObject]

    Parameters

    image

    The image to get results in.

    error

    An optional error parameter populated when there is an error getting results.

    Return Value

    Array of object results in the given image or nil if there was an error.