Updated iOS gesture recognizer documentation to use Swift names

This commit is contained in:
Prianka Liz Kariat 2023-09-08 19:15:56 +05:30
parent 900e637b6a
commit 18f16f6bb5
3 changed files with 71 additions and 71 deletions

View File

@ -31,51 +31,52 @@ NS_SWIFT_NAME(GestureRecognizer)
@interface MPPGestureRecognizer : NSObject @interface MPPGestureRecognizer : NSObject
/** /**
* Creates a new instance of `MPPGestureRecognizer` from an absolute path to a TensorFlow Lite model * Creates a new instance of `GestureRecognizer` from an absolute path to a TensorFlow Lite model
* file stored locally on the device and the default `MPPGestureRecognizerOptions`. * file stored locally on the device and the default `GestureRecognizerOptions`.
* *
* @param modelPath An absolute path to a TensorFlow Lite model file stored locally on the device. * @param modelPath An absolute path to a TensorFlow Lite model file stored locally on the device.
* @param error An optional error parameter populated when there is an error in initializing the * @param error An optional error parameter populated when there is an error in initializing the
* gesture recognizer. * gesture recognizer.
* *
* @return A new instance of `MPPGestureRecognizer` with the given model path. `nil` if there is an * @return A new instance of `GestureRecognizer` with the given model path. `nil` if there is an
* error in initializing the gesture recognizer. * error in initializing the gesture recognizer.
*/ */
- (nullable instancetype)initWithModelPath:(NSString *)modelPath error:(NSError **)error; - (nullable instancetype)initWithModelPath:(NSString *)modelPath error:(NSError **)error;
/** /**
* Creates a new instance of `MPPGestureRecognizer` from the given `MPPGestureRecognizerOptions`. * Creates a new instance of `GestureRecognizer` from the given `GestureRecognizerOptions`.
* *
* @param options The options of type `MPPGestureRecognizerOptions` to use for configuring the * @param options The options of type `GestureRecognizerOptions` to use for configuring the
* `MPPGestureRecognizer`. * `GestureRecognizer`.
* @param error An optional error parameter populated when there is an error in initializing the * @param error An optional error parameter populated when there is an error in initializing the
* gesture recognizer. * gesture recognizer.
* *
* @return A new instance of `MPPGestureRecognizer` with the given options. `nil` if there is an * @return A new instance of `GestureRecognizer` with the given options. `nil` if there is an error
* error in initializing the gesture recognizer. * in initializing the gesture recognizer.
*/ */
- (nullable instancetype)initWithOptions:(MPPGestureRecognizerOptions *)options - (nullable instancetype)initWithOptions:(MPPGestureRecognizerOptions *)options
error:(NSError **)error NS_DESIGNATED_INITIALIZER; error:(NSError **)error NS_DESIGNATED_INITIALIZER;
/** /**
* Performs gesture recognition on the provided MPPImage using the whole image as region of * 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 * interest. Rotation will be applied according to the `orientation` property of the provided
* `MPPImage`. Only use this method when the `MPPGestureRecognizer` is created with * `MPImage`. Only use this method when the `GestureRecognizer` is created with running mode,
* `MPPRunningModeImage`. * `.image`.
* This method supports gesture recognition of RGBA images. If your `MPPImage` has a source type of *
* `MPPImageSourceTypePixelBuffer` or `MPPImageSourceTypeSampleBuffer`, the underlying pixel buffer * This method supports gesture recognition of RGBA images. If your `MPImage` has a source type of
* must have one of the following pixel format types: * `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must have one of the following
* pixel format types:
* 1. kCVPixelFormatType_32BGRA * 1. kCVPixelFormatType_32BGRA
* 2. kCVPixelFormatType_32RGBA * 2. kCVPixelFormatType_32RGBA
* *
* If your `MPPImage` has a source type of `MPPImageSourceTypeImage` ensure that the color space is * If your `MPImage` has a source type of `.image` ensure that the color space is RGB with an Alpha
* RGB with an Alpha channel. * channel.
* *
* @param image The `MPPImage` on which gesture recognition is to be performed. * @param image The `MPImage` on which gesture recognition is to be performed.
* @param error An optional error parameter populated when there is an error in performing gesture * @param error An optional error parameter populated when there is an error in performing gesture
* recognition on the input image. * recognition on the input image.
* *
* @return An `MPPGestureRecognizerResult` object that contains the hand gesture recognition * @return An `GestureRecognizerResult` object that contains the hand gesture recognition
* results. * results.
*/ */
- (nullable MPPGestureRecognizerResult *)recognizeImage:(MPPImage *)image - (nullable MPPGestureRecognizerResult *)recognizeImage:(MPPImage *)image
@ -83,30 +84,30 @@ NS_SWIFT_NAME(GestureRecognizer)
NS_SWIFT_NAME(recognize(image:)); NS_SWIFT_NAME(recognize(image:));
/** /**
* Performs gesture recognition on the provided video frame of type `MPPImage` using the whole * Performs gesture recognition on the provided video frame of type `MPImage` using the whole image
* image as region of interest. Rotation will be applied according to the `orientation` property of * as region of interest. Rotation will be applied according to the `orientation` property of the
* the provided `MPPImage`. Only use this method when the `MPPGestureRecognizer` is created with * provided `MPImage`. Only use this method when the `GestureRecognizer` is created with running
* `MPPRunningModeVideo`. * mode, `.video`.
* *
* It's required to provide the video frame's timestamp (in milliseconds). The input timestamps must * It's required to provide the video frame's timestamp (in milliseconds). The input timestamps must
* be monotonically increasing. * be monotonically increasing.
* *
* This method supports gesture recognition of RGBA images. If your `MPPImage` has a source type of * This method supports gesture recognition of RGBA images. If your `MPImage` has a source type of
* `MPPImageSourceTypePixelBuffer` or `MPPImageSourceTypeSampleBuffer`, the underlying pixel buffer * `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must have one of the following
* must have one of the following pixel format types: * pixel format types:
* 1. kCVPixelFormatType_32BGRA * 1. kCVPixelFormatType_32BGRA
* 2. kCVPixelFormatType_32RGBA * 2. kCVPixelFormatType_32RGBA
* *
* If your `MPPImage` has a source type of `MPPImageSourceTypeImage` ensure that the color space is * If your `MPImage` has a source type of `.image` ensure that the color space is RGB with an Alpha
* RGB with an Alpha channel. * channel.
* *
* @param image The `MPPImage` on which gesture recognition is to be performed. * @param image The `MPImage` on which gesture recognition is to be performed.
* @param timestampInMilliseconds The video frame's timestamp (in milliseconds). The input * @param timestampInMilliseconds The video frame's timestamp (in milliseconds). The input
* timestamps must be monotonically increasing. * timestamps must be monotonically increasing.
* @param error An optional error parameter populated when there is an error in performing gesture * @param error An optional error parameter populated when there is an error in performing gesture
* recognition on the input video frame. * recognition on the input video frame.
* *
* @return An `MPPGestureRecognizerResult` object that contains the hand gesture recognition * @return An `GestureRecognizerResult` object that contains the hand gesture recognition
* results. * results.
*/ */
- (nullable MPPGestureRecognizerResult *)recognizeVideoFrame:(MPPImage *)image - (nullable MPPGestureRecognizerResult *)recognizeVideoFrame:(MPPImage *)image
@ -115,33 +116,33 @@ NS_SWIFT_NAME(GestureRecognizer)
NS_SWIFT_NAME(recognize(videoFrame:timestampInMilliseconds:)); NS_SWIFT_NAME(recognize(videoFrame:timestampInMilliseconds:));
/** /**
* Sends live stream image data of type `MPPImage` to perform gesture recognition using the whole * Sends live stream image data of type `MPImage` to perform gesture recognition using the whole
* image as region of interest. Rotation will be applied according to the `orientation` property of * image as region of interest. Rotation will be applied according to the `orientation` property of
* the provided `MPPImage`. Only use this method when the `MPPGestureRecognizer` is created with * the provided `MPImage`. Only use this method when the `GestureRecognizer` is created with running
* `MPPRunningModeLiveStream`. * mode, `.liveStream`.
* *
* The object which needs to be continuously notified of the available results of gesture * The object which needs to be continuously notified of the available results of gesture
* recognition must confirm to `MPPGestureRecognizerLiveStreamDelegate` protocol and implement the * recognition must confirm to `GestureRecognizerLiveStreamDelegate` protocol and implement the
* `gestureRecognizer:didFinishRecognitionWithResult:timestampInMilliseconds:error:` * `gestureRecognizer(_:didFinishRecognitionWithResult:timestampInMilliseconds:error:)`
* delegate method. * delegate method.
* *
* It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent * It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent
* to the gesture recognizer. The input timestamps must be monotonically increasing. * to the gesture recognizer. The input timestamps must be monotonically increasing.
* *
* This method supports gesture recognition of RGBA images. If your `MPPImage` has a source type of * This method supports gesture recognition of RGBA images. If your `MPImage` has a source type of
* `MPPImageSourceTypePixelBuffer` or `MPPImageSourceTypeSampleBuffer`, the underlying pixel buffer * `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must have one of the following
* must have one of the following pixel format types: * pixel format types:
* 1. kCVPixelFormatType_32BGRA * 1. kCVPixelFormatType_32BGRA
* 2. kCVPixelFormatType_32RGBA * 2. kCVPixelFormatType_32RGBA
* *
* If the input `MPPImage` has a source type of `MPPImageSourceTypeImage` ensure that the color * If the input `MPImage` has a source type of `.image` ensure that the color space is RGB with an
* space is RGB with an Alpha channel. * Alpha channel.
* *
* If this method is used for performing gesture recognition on live camera frames using * If this method is used for performing gesture recognition on live camera frames using
* `AVFoundation`, ensure that you request `AVCaptureVideoDataOutput` to output frames in * `AVFoundation`, ensure that you request `AVCaptureVideoDataOutput` to output frames in
* `kCMPixelFormat_32RGBA` using its `videoSettings` property. * `kCMPixelFormat_32RGBA` using its `videoSettings` property.
* *
* @param image A live stream image data of type `MPPImage` on which gesture recognition is to be * @param image A live stream image data of type `MPImage` on which gesture recognition is to be
* performed. * performed.
* @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input * @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input
* image is sent to the gesture recognizer. The input timestamps must be monotonically increasing. * image is sent to the gesture recognizer. The input timestamps must be monotonically increasing.

View File

@ -24,12 +24,12 @@ NS_ASSUME_NONNULL_BEGIN
@class MPPGestureRecognizer; @class MPPGestureRecognizer;
/** /**
* This protocol defines an interface for the delegates of `MPPGestureRecognizer` object to receive * This protocol defines an interface for the delegates of `GestureRecognizer` object to receive
* results of performing asynchronous gesture recognition on images (i.e, when `runningMode` = * results of performing asynchronous gesture recognition on images (i.e, when `runningMode` =
* `MPPRunningModeLiveStream`). * `.liveStream`).
* *
* The delegate of `MPPGestureRecognizer` must adopt `MPPGestureRecognizerLiveStreamDelegate` * The delegate of `GestureRecognizer` must adopt `GestureRecognizerLiveStreamDelegate` protocol.
* protocol. The methods in this protocol are optional. * The methods in this protocol are optional.
*/ */
NS_SWIFT_NAME(GestureRecognizerLiveStreamDelegate) NS_SWIFT_NAME(GestureRecognizerLiveStreamDelegate)
@protocol MPPGestureRecognizerLiveStreamDelegate <NSObject> @protocol MPPGestureRecognizerLiveStreamDelegate <NSObject>
@ -37,15 +37,15 @@ NS_SWIFT_NAME(GestureRecognizerLiveStreamDelegate)
@optional @optional
/** /**
* This method notifies a delegate that the results of asynchronous gesture recognition of * This method notifies a delegate that the results of asynchronous gesture recognition of an image
* an image submitted to the `MPPGestureRecognizer` is available. * submitted to the `GestureRecognizer` is available.
* *
* This method is called on a private serial dispatch queue created by the `MPPGestureRecognizer` * This method is called on a private serial dispatch queue created by the `GestureRecognizer` for
* for performing the asynchronous delegates calls. * performing the asynchronous delegates calls.
* *
* @param gestureRecognizer The gesture recognizer which performed the gesture recognition. * @param gestureRecognizer The gesture recognizer which performed the gesture recognition. This is
* This is useful to test equality when there are multiple instances of `MPPGestureRecognizer`. * useful to test equality when there are multiple instances of `GestureRecognizer`.
* @param result The `MPPGestureRecognizerResult` object that contains a list of detections, each * @param result The `GestureRecognizerResult` object that contains a list of detections, each
* detection has a bounding box that is expressed in the unrotated input frame of reference * detection has a bounding box that is expressed in the unrotated input frame of reference
* coordinates system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the * coordinates system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the
* underlying image data. * underlying image data.
@ -62,26 +62,25 @@ NS_SWIFT_NAME(GestureRecognizerLiveStreamDelegate)
NS_SWIFT_NAME(gestureRecognizer(_:didFinishGestureRecognition:timestampInMilliseconds:error:)); NS_SWIFT_NAME(gestureRecognizer(_:didFinishGestureRecognition:timestampInMilliseconds:error:));
@end @end
/** Options for setting up a `MPPGestureRecognizer`. */ /** Options for setting up a `GestureRecognizer`. */
NS_SWIFT_NAME(GestureRecognizerOptions) NS_SWIFT_NAME(GestureRecognizerOptions)
@interface MPPGestureRecognizerOptions : MPPTaskOptions <NSCopying> @interface MPPGestureRecognizerOptions : MPPTaskOptions <NSCopying>
/** /**
* Running mode of the gesture recognizer task. Defaults to `MPPRunningModeImage`. * Running mode of the gesture recognizer task. Defaults to `.video`.
* `MPPGestureRecognizer` can be created with one of the following running modes: * `GestureRecognizer` can be created with one of the following running modes:
* 1. `MPPRunningModeImage`: The mode for performing gesture recognition on single image inputs. * 1. `image`: The mode for performing gesture recognition on single image inputs.
* 2. `MPPRunningModeVideo`: The mode for performing gesture recognition on the decoded frames of a * 2. `video`: The mode for performing gesture recognition on the decoded frames of a video.
* video. * 3. `liveStream`: The mode for performing gesture recognition on a live stream of input data,
* 3. `MPPRunningModeLiveStream`: The mode for performing gesture recognition on a live stream of * such as from the camera.
* input data, such as from the camera.
*/ */
@property(nonatomic) MPPRunningMode runningMode; @property(nonatomic) MPPRunningMode runningMode;
/** /**
* An object that confirms to `MPPGestureRecognizerLiveStreamDelegate` protocol. This object must * An object that confirms to `GestureRecognizerLiveStreamDelegate` protocol. This object must
* implement `gestureRecognizer:didFinishRecognitionWithResult:timestampInMilliseconds:error:` to * implement `gestureRecognizer(_:didFinishRecognitionWithResult:timestampInMilliseconds:error:)` to
* receive the results of performing asynchronous gesture recognition on images (i.e, when * receive the results of performing asynchronous gesture recognition on images (i.e, when
* `runningMode` = `MPPRunningModeLiveStream`). * `runningMode` = `.liveStream`).
*/ */
@property(nonatomic, weak, nullable) id<MPPGestureRecognizerLiveStreamDelegate> @property(nonatomic, weak, nullable) id<MPPGestureRecognizerLiveStreamDelegate>
gestureRecognizerLiveStreamDelegate; gestureRecognizerLiveStreamDelegate;
@ -99,18 +98,18 @@ NS_SWIFT_NAME(GestureRecognizerOptions)
@property(nonatomic) float minTrackingConfidence; @property(nonatomic) float minTrackingConfidence;
/** /**
* Sets the optional `MPPClassifierOptions` controlling the canned gestures classifier, such as * Sets the optional `ClassifierOptions` controlling the canned gestures classifier, such as score
* score threshold, allow list and deny list of gestures. The categories for canned gesture * threshold, allow list and deny list of gestures. The categories for canned gesture classifiers
* classifiers are: ["None", "Closed_Fist", "Open_Palm", "Pointing_Up", "Thumb_Down", "Thumb_Up", * are: ["None", "Closed_Fist", "Open_Palm", "Pointing_Up", "Thumb_Down", "Thumb_Up", "Victory",
* "Victory", "ILoveYou"]. * "ILoveYou"].
* *
* TODO: Note this option is subject to change, after scoring merging calculator is implemented. * TODO: Note this option is subject to change, after scoring merging calculator is implemented.
*/ */
@property(nonatomic, copy, nullable) MPPClassifierOptions *cannedGesturesClassifierOptions; @property(nonatomic, copy, nullable) MPPClassifierOptions *cannedGesturesClassifierOptions;
/** /**
* Sets the optional {@link ClassifierOptions} controlling the custom gestures classifier, such as * Sets the optional `ClassifierOptions` controlling the custom gestures classifier, such as score
* score threshold, allow list and deny list of gestures. * threshold, allow list and deny list of gestures.
* *
* TODO: Note this option is subject to change, after scoring merging calculator is implemented. * TODO: Note this option is subject to change, after scoring merging calculator is implemented.
*/ */

View File

@ -20,7 +20,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** Represents the gesture recognition results generated by MPPGestureRecognizer. */ /** Represents the gesture recognition results generated by `GestureRecognizer`. */
NS_SWIFT_NAME(GestureRecognizerResult) NS_SWIFT_NAME(GestureRecognizerResult)
@interface MPPGestureRecognizerResult : MPPTaskResult @interface MPPGestureRecognizerResult : MPPTaskResult
@ -41,7 +41,7 @@ NS_SWIFT_NAME(GestureRecognizerResult)
@property(nonatomic, readonly) NSArray<NSArray<MPPCategory *> *> *gestures; @property(nonatomic, readonly) NSArray<NSArray<MPPCategory *> *> *gestures;
/** /**
* Initializes a new `MPPGestureRecognizerResult` with the given landmarks, world landmarks, * Initializes a new `GestureRecognizerResult` with the given landmarks, world landmarks,
* handedness, gestures and timestamp (in milliseconds). * handedness, gestures and timestamp (in milliseconds).
* *
* @param landmarks The hand landmarks of detected hands. * @param landmarks The hand landmarks of detected hands.
@ -50,7 +50,7 @@ NS_SWIFT_NAME(GestureRecognizerResult)
* @param handedness The recognized hand gestures of detected hands. * @param handedness The recognized hand gestures of detected hands.
* @param timestampInMilliseconds The timestamp for this result. * @param timestampInMilliseconds The timestamp for this result.
* *
* @return An instance of `MPPGestureRecognizerResult` initialized with the given landmarks, world * @return An instance of `GestureRecognizerResult` initialized with the given landmarks, world
* landmarks, handedness and gestures. * landmarks, handedness and gestures.
* *
*/ */