MediaPipeTasksVision Framework Reference

GestureRecognizer

class GestureRecognizer : NSObject

@brief Performs gesture recognition on images.

This API expects a pre-trained TFLite hand gesture recognizer model or a custom one created using MediaPipe Solutions Model Maker. See https://developers.google.com/mediapipe/solutions/model_maker.

  • Creates a new instance of GestureRecognizer from an absolute path to a TensorFlow Lite model file stored locally on the device and the default GestureRecognizerOptions.

    Declaration

    Swift

    convenience init(modelPath: String) throws

    Parameters

    modelPath

    An absolute path to a TensorFlow Lite model file stored locally on the device.

    error

    An optional error parameter populated when there is an error in initializing the gesture recognizer.

    Return Value

    A new instance of GestureRecognizer with the given model path. nil if there is an error in initializing the gesture recognizer.

  • Creates a new instance of GestureRecognizer from the given GestureRecognizerOptions.

    Declaration

    Swift

    init(options: GestureRecognizerOptions) throws

    Parameters

    options

    The options of type GestureRecognizerOptions to use for configuring the GestureRecognizer.

    error

    An optional error parameter populated when there is an error in initializing the gesture recognizer.

    Return Value

    A new instance of GestureRecognizer with the given options. nil if there is an error in initializing the gesture recognizer.

  • Performs gesture recognition on the provided MPImage using the whole image as region of interest. Rotation will be applied according to the orientation property of the provided MPImage. Only use this method when the GestureRecognizer is created with running mode, .image.

    This method supports performing gesture recognition on RGBA images. If your MPImage has a source type of .pixelBuffer or .sampleBuffer, the underlying pixel buffer must use kCVPixelFormatType_32BGRA as its pixel format.

    If your MPImage has a source type of .image ensure that the color space is RGB with an Alpha channel.

    Declaration

    Swift