MPPHandLandmarker
@interface MPPHandLandmarker : NSObject
@brief Performs hand landmarks detection on images.
This API expects a pre-trained hand landmarks model asset bundle.
-
The array of connections between the landmarks in the palm.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handPalmConnections;
-
The array of connections between the landmarks in the thumb.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handThumbConnections;
-
The array of connections between the landmarks in the index finger.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handIndexFingerConnections;
-
The array of connections between the landmarks in the middle finger.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handMiddleFingerConnections;
-
The array of connections between the landmarks in the ring finger.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handRingFingerConnections;
-
The array of connections between the landmarks in the pinky.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handPinkyConnections;
-
The array of connections between all the landmarks in the hand.
Declaration
Objective-C
@property (class, nonatomic, readonly) NSArray<MPPConnection *> *_Nonnull handConnections;
-
Creates a new instance of
HandLandmarker
from an absolute path to a model asset bundle stored locally on the device and the defaultHandLandmarkerOptions
.Declaration
Objective-C
- (nullable instancetype)initWithModelPath:(nonnull NSString *)modelPath error:(NSError *_Nullable *_Nullable)error;
Parameters
modelPath
An absolute path to a model asset bundle stored locally on the device.
error
An optional error parameter populated when there is an error in initializing the hand landmarker.
Return Value
A new instance of
HandLandmarker
with the given model path.nil
if there is an error in initializing the hand landmarker. -
Creates a new instance of
HandLandmarker
from the givenHandLandmarkerOptions
.Declaration
Objective-C
- (nullable instancetype)initWithOptions: (nonnull MPPHandLandmarkerOptions *)options error:(NSError *_Nullable *_Nullable)error;
Parameters
options
The options of type
HandLandmarkerOptions
to use for configuring theHandLandmarker
.error
An optional error parameter populated when there is an error in initializing the hand landmarker.
Return Value
A new instance of
HandLandmarker
with the given options.nil
if there is an error in initializing the hand landmarker. -
Performs hand landmarks detection on the provided
MPImage
using the whole image as region of interest. Rotation will be applied according to theorientation
property of the providedMPImage
. Only use this method when theHandLandmarker
is created with running mode,.image
.This method supports performing hand landmarks detection on RGBA images. If your
MPImage
has a source type of.pixelBuffer
or.sampleBuffer
, the underlying pixel buffer must usekCVPixelFormatType_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
Objective-C
- (nullable MPPHandLandmarkerResult *) detectImage:(nonnull MPPImage *)image error:(NSError *_Nullable *_Nullable)error;
Parameters
image
The
MPImage
on which hand landmarks detection is to be performed.error
An optional error parameter populated when there is an error in performing hand landmarks detection on the input image.
Return Value
An
HandLandmarkerResult
object that contains the hand hand landmarks detection results. -
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 theorientation
property of the providedMPImage
. Only use this method when theHandLandmarker
is created with running mode,.video
.It’s required to provide the video frame’s timestamp (in milliseconds). The input timestamps must be monotonically increasing.
This method supports performing hand landmarks detection on RGBA images. If your
MPImage
has a source type of.pixelBuffer
or.sampleBuffer
, the underlying pixel buffer must usekCVPixelFormatType_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
Objective-C
- (nullable MPPHandLandmarkerResult *) detectVideoFrame:(nonnull MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError *_Nullable *_Nullable)error;
Parameters
image
The
MPImage
on which hand landmarks detection is to be performed.timestampInMilliseconds
The video frame’s timestamp (in milliseconds). The input timestamps must be monotonically increasing.
error
An optional error parameter populated when there is an error in performing hand landmarks detection on the input video frame.
Return Value
An
HandLandmarkerResult
object that contains the hand hand landmarks detection results. -
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 theorientation
property of the providedMPImage
. Only use this method when theHandLandmarker
is created with running mode,.liveStream
.The object which needs to be continuously notified of the available results of hand landmarks detection must confirm to
HandLandmarkerLiveStreamDelegate
protocol and implement thehandLandmarker(_:didFinishDetectionWithResult:timestampInMilliseconds:error:)
delegate method.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.
This method supports performing hand landmarks detection on RGBA images. If your
MPImage
has a source type of.pixelBuffer
or.sampleBuffer
, the underlying pixel buffer must usekCVPixelFormatType_32BGRA
as its pixel format.If the input
MPImage
has a source type of.image
ensure that the color space is RGB with an Alpha channel.If this method is used for performing hand landmarks detection on live camera frames using
AVFoundation
, ensure that you requestAVCaptureVideoDataOutput
to output frames inkCMPixelFormat_32BGRA
using itsvideoSettings
property.Declaration
Objective-C
- (BOOL)detectAsyncImage:(nonnull MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError *_Nullable *_Nullable)error;
Parameters
image
A live stream image data of type
MPImage
on which hand landmarks detection is to be performed.timestampInMilliseconds
The timestamp (in milliseconds) which indicates when the input image is sent to the hand landmarker. The input timestamps must be monotonically increasing.
error
An optional error parameter populated when there is an error in performing hand landmarks detection on the input live stream image data.
Return Value
YES
if the image was sent to the task successfully, otherwiseNO
. -
Undocumented
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE;
-
Undocumented
Declaration
Objective-C
+ (instancetype)new NS_UNAVAILABLE;