Updated iOS hand landmarker documentation to use swift names

This commit is contained in:
Prianka Liz Kariat 2023-09-08 19:16:15 +05:30
parent 18f16f6bb5
commit 75daf4e756
3 changed files with 62 additions and 66 deletions

View File

@ -48,82 +48,81 @@ NS_SWIFT_NAME(HandLandmarker)
@property(class, nonatomic, readonly) NSArray<MPPConnection *> *handConnections; @property(class, nonatomic, readonly) NSArray<MPPConnection *> *handConnections;
/** /**
* Creates a new instance of `MPPHandLandmarker` from an absolute path to a model asset bundle * Creates a new instance of `HandLandmarker` from an absolute path to a model asset bundle stored
* stored locally on the device and the default `MPPHandLandmarkerOptions`. * locally on the device and the default `HandLandmarkerOptions`.
* *
* @param modelPath An absolute path to a model asset bundle stored locally on the device. * @param modelPath An absolute path to a model asset bundle 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
* hand landmarker. * hand landmarker.
* *
* @return A new instance of `MPPHandLandmarker` with the given model path. `nil` if there is an * @return A new instance of `HandLandmarker` with the given model path. `nil` if there is an error
* error in initializing the hand landmarker. * in initializing the hand landmarker.
*/ */
- (nullable instancetype)initWithModelPath:(NSString *)modelPath error:(NSError **)error; - (nullable instancetype)initWithModelPath:(NSString *)modelPath error:(NSError **)error;
/** /**
* Creates a new instance of `MPPHandLandmarker` from the given `MPPHandLandmarkerOptions`. * Creates a new instance of `HandLandmarker` from the given `HandLandmarkerOptions`.
* *
* @param options The options of type `MPPHandLandmarkerOptions` to use for configuring the * @param options The options of type `HandLandmarkerOptions` to use for configuring the
* `MPPHandLandmarker`. * `HandLandmarker`.
* @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
* hand landmarker. * hand landmarker.
* *
* @return A new instance of `MPPHandLandmarker` with the given options. `nil` if there is an * @return A new instance of `HandLandmarker` with the given options. `nil` if there is an error in
* error in initializing the hand landmarker. * initializing the hand landmarker.
*/ */
- (nullable instancetype)initWithOptions:(MPPHandLandmarkerOptions *)options - (nullable instancetype)initWithOptions:(MPPHandLandmarkerOptions *)options
error:(NSError **)error NS_DESIGNATED_INITIALIZER; error:(NSError **)error NS_DESIGNATED_INITIALIZER;
/** /**
* Performs hand landmarks detection on the provided `MPPImage` using the whole image as region of * Performs hand landmarks detection 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 `MPPHandLandmarker` is created with * `MPImage`. Only use this method when the `HandLandmarker` is created with running mode, `.image`.
* `MPPRunningModeImage`.
* *
* This method supports performing hand landmarks detection on RGBA images. If your `MPPImage` has a * This method supports performing hand landmarks detection on RGBA images. If your `MPImage` has a
* source type of `MPPImageSourceTypePixelBuffer` or `MPPImageSourceTypeSampleBuffer`, the * source type of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must have one of
* underlying pixel buffer must have one of the following pixel format types: * 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 hand landmarks detection is to be performed. * @param image The `MPImage` on which hand landmarks detection is to be performed.
* @param error An optional error parameter populated when there is an error in performing hand * @param error An optional error parameter populated when there is an error in performing hand
* landmarks detection on the input image. * landmarks detection on the input image.
* *
* @return An `MPPHandLandmarkerResult` object that contains the hand hand landmarks detection * @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection
* results. * results.
*/ */
- (nullable MPPHandLandmarkerResult *)detectInImage:(MPPImage *)image - (nullable MPPHandLandmarkerResult *)detectInImage:(MPPImage *)image
error:(NSError **)error NS_SWIFT_NAME(detect(image:)); error:(NSError **)error NS_SWIFT_NAME(detect(image:));
/** /**
* Performs hand landmarks detection on the provided video frame of type `MPPImage` using the whole * Performs hand landmarks detection on the provided video frame of type `MPImage` 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 `MPPHandLandmarker` is created with * the provided `MPImage`. Only use this method when the `HandLandmarker` 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 performing hand landmarks detection on RGBA images. If your `MPPImage` has a * This method supports performing hand landmarks detection on RGBA images. If your `MPImage` has a
* source type of `MPPImageSourceTypePixelBuffer` or `MPPImageSourceTypeSampleBuffer`, the * source type of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must have one of
* underlying pixel buffer must have one of the following pixel format types: * 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 hand landmarks detection is to be performed. * @param image The `MPImage` on which hand landmarks detection 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 hand * @param error An optional error parameter populated when there is an error in performing hand
* landmarks detection on the input video frame. * landmarks detection on the input video frame.
* *
* @return An `MPPHandLandmarkerResult` object that contains the hand hand landmarks detection * @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection
* results. * results.
*/ */
- (nullable MPPHandLandmarkerResult *)detectInVideoFrame:(MPPImage *)image - (nullable MPPHandLandmarkerResult *)detectInVideoFrame:(MPPImage *)image
@ -132,33 +131,32 @@ NS_SWIFT_NAME(HandLandmarker)
NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:)); NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:));
/** /**
* Sends live stream image data of type `MPPImage` to perform hand landmarks detection using the * Sends live stream image data of type `MPImage` to perform hand landmarks detection using the
* whole image as region of interest. Rotation will be applied according to the `orientation` * whole image as region of interest. Rotation will be applied according to the `orientation`
* property of the provided `MPPImage`. Only use this method when the `MPPHandLandmarker` is created * property of the provided `MPImage`. Only use this method when the `HandLandmarker` is created
* with `MPPRunningModeLiveStream`. * with running mode, `.liveStream`.
* *
* The object which needs to be continuously notified of the available results of hand landmarks * The object which needs to be continuously notified of the available results of hand landmarks
* detection must confirm to `MPPHandLandmarkerLiveStreamDelegate` protocol and implement the * detection must confirm to `HandLandmarkerLiveStreamDelegate` protocol and implement the
* `handLandmarker:didFinishDetectionWithResult:timestampInMilliseconds:error:` * `handLandmarker(_:didFinishDetectionWithResult: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 hand landmarker. The input timestamps must be monotonically increasing. * to the hand landmarker. The input timestamps must be monotonically increasing.
* *
* This method supports performing hand landmarks detection on RGBA images. If your `MPPImage` has a * This method supports performing hand landmarks detection on RGBA images. If your `MPImage` has a
* source type of `MPPImageSourceTypePixelBuffer` or `MPPImageSourceTypeSampleBuffer`, the * source type of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must have one of
* underlying pixel buffer must have one of the following pixel format types: * the following 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 hand landmarks detection on live camera frames using * If this method is used for performing hand landmarks detection 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 hand landmarks detection is to * @param image A live stream image data of type `MPImage` on which hand landmarks detection is to
* be performed. * be 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 hand landmarker. The input timestamps must be monotonically increasing. * image is sent to the hand landmarker. The input timestamps must be monotonically increasing.

View File

@ -23,11 +23,11 @@ NS_ASSUME_NONNULL_BEGIN
@class MPPHandLandmarker; @class MPPHandLandmarker;
/** /**
* This protocol defines an interface for the delegates of `MPPHandLandmarker` object to receive * This protocol defines an interface for the delegates of `HandLandmarker` object to receive
* results of performing asynchronous hand landmark detection on images (i.e, when `runningMode` = * results of performing asynchronous hand landmark detection on images (i.e, when
* `MPPRunningModeLiveStream`). * `runningMode` = `.liveStream`).
* *
* The delegate of `MPPHandLandmarker` must adopt `MPPHandLandmarkerLiveStreamDelegate` protocol. * The delegate of `HandLandmarker` must adopt `HandLandmarkerLiveStreamDelegate` protocol.
* The methods in this protocol are optional. * The methods in this protocol are optional.
*/ */
NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate) NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate)
@ -37,14 +37,14 @@ NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate)
/** /**
* This method notifies a delegate that the results of asynchronous hand landmark detection of an * This method notifies a delegate that the results of asynchronous hand landmark detection of an
* image submitted to the `MPPHandLandmarker` is available. * image submitted to the `HandLandmarker` is available.
* *
* This method is called on a private serial dispatch queue created by the `MPPHandLandmarker` * This method is called on a private serial dispatch queue created by the `HandLandmarker` for
* for performing the asynchronous delegates calls. * performing the asynchronous delegates calls.
* *
* @param handLandmarker The hand landmarker which performed the hand landmarking. * @param handLandmarker The hand landmarker which performed the hand landmarking.
* This is useful to test equality when there are multiple instances of `MPPHandLandmarker`. * This is useful to test equality when there are multiple instances of `HandLandmarker`.
* @param result The `MPPHandLandmarkerResult` object that contains a list of detections, each * @param result The `HandLandmarkerResult` 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.
@ -60,32 +60,30 @@ NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate)
NS_SWIFT_NAME(handLandmarker(_:didFinishDetection:timestampInMilliseconds:error:)); NS_SWIFT_NAME(handLandmarker(_:didFinishDetection:timestampInMilliseconds:error:));
@end @end
/** Options for setting up a `MPPHandLandmarker`. */ /** Options for setting up a `HandLandmarker`. */
NS_SWIFT_NAME(HandLandmarkerOptions) NS_SWIFT_NAME(HandLandmarkerOptions)
@interface MPPHandLandmarkerOptions : MPPTaskOptions <NSCopying> @interface MPPHandLandmarkerOptions : MPPTaskOptions <NSCopying>
/** /**
* Running mode of the hand landmarker task. Defaults to `MPPRunningModeImage`. * Running mode of the hand landmarker task. Defaults to `.image`.
* `MPPHandLandmarker` can be created with one of the following running modes: * `HandLandmarker` can be created with one of the following running modes:
* 1. `MPPRunningModeImage`: The mode for performing hand landmark detection on single image * 1. `image`: The mode for performing hand landmark detection on single image inputs.
* inputs. * 2. `video`: The mode for performing hand landmark detection on the decoded frames of a video.
* 2. `MPPRunningModeVideo`: The mode for performing hand landmark detection on the decoded frames * 3. `liveStream`: The mode for performing hand landmark detection on a live stream of input data,
* of a video. * such as from the camera.
* 3. `MPPRunningModeLiveStream`: The mode for performing hand landmark detection on a live stream
* of input data, such as from the camera.
*/ */
@property(nonatomic) MPPRunningMode runningMode; @property(nonatomic) MPPRunningMode runningMode;
/** /**
* An object that confirms to `MPPHandLandmarkerLiveStreamDelegate` protocol. This object must * An object that confirms to `HandLandmarkerLiveStreamDelegate` protocol. This object must
* implement `handLandmarker:didFinishDetectionWithResult:timestampInMilliseconds:error:` to * implement `handLandmarker:didFinishDetectionWithResult:timestampInMilliseconds:error:` to
* receive the results of performing asynchronous hand landmark detection on images (i.e, when * receive the results of performing asynchronous hand landmark detection on images (i.e, when
* `runningMode` = `MPPRunningModeLiveStream`). * `runningMode` = `.liveStream`).
*/ */
@property(nonatomic, weak, nullable) id<MPPHandLandmarkerLiveStreamDelegate> @property(nonatomic, weak, nullable) id<MPPHandLandmarkerLiveStreamDelegate>
handLandmarkerLiveStreamDelegate; handLandmarkerLiveStreamDelegate;
/** The maximum number of hands that can be detected by the `MPPHandLandmarker`. */ /** The maximum number of hands that can be detected by the `HandLandmarker`. */
@property(nonatomic) NSInteger numHands; @property(nonatomic) NSInteger numHands;
/** The minimum confidence score for the hand detection to be considered successful. */ /** The minimum confidence score for the hand detection to be considered successful. */

View File

@ -20,7 +20,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** Represents the hand landmarker results generated by MPPHandLandmarker. */ /** Represents the hand landmarker results generated by `HandLandmarker`. */
NS_SWIFT_NAME(HandLandmarkerResult) NS_SWIFT_NAME(HandLandmarkerResult)
@interface MPPHandLandmarkerResult : MPPTaskResult @interface MPPHandLandmarkerResult : MPPTaskResult
@ -34,15 +34,15 @@ NS_SWIFT_NAME(HandLandmarkerResult)
@property(nonatomic, readonly) NSArray<NSArray<MPPCategory *> *> *handedness; @property(nonatomic, readonly) NSArray<NSArray<MPPCategory *> *> *handedness;
/** /**
* Initializes a new `MPPHandLandmarkerResult` with the given landmarks, world landmarks, * Initializes a new `HandLandmarkerResult` with the given landmarks, world landmarks, handedness
* handedness and timestamp (in milliseconds). * and timestamp (in milliseconds).
* *
* @param landmarks The hand landmarks of detected hands. * @param landmarks The hand landmarks of detected hands.
* @param worldLandmarks The hand landmarks in world coordniates of detected hands. * @param worldLandmarks The hand landmarks in world coordniates of detected hands.
* @param handedness The handedness of detected hands. * @param handedness The handedness of detected hands.
* @param timestampInMilliseconds The timestamp for this result. * @param timestampInMilliseconds The timestamp for this result.
* *
* @return An instance of `MPPGHandLandmarkerResult` initialized with the given landmarks, world * @return An instance of `HandLandmarkerResult` initialized with the given landmarks, world
* landmarks, handedness and timestamp (in milliseconds). * landmarks, handedness and timestamp (in milliseconds).
* *
*/ */