From f124cad0955fa8c60538058fc233e524d759d0c7 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 10:57:58 +0530 Subject: [PATCH 1/9] Added iOS hand landmarker result --- .../tasks/ios/vision/hand_landmarker/BUILD | 29 ++++++++++ .../sources/MPPHandLandmarkerResult.h | 56 +++++++++++++++++++ .../sources/MPPHandLandmarkerResult.m | 32 +++++++++++ 3 files changed, 117 insertions(+) create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/BUILD create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.m diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/BUILD b/mediapipe/tasks/ios/vision/hand_landmarker/BUILD new file mode 100644 index 000000000..62ad4d4d0 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/BUILD @@ -0,0 +1,29 @@ +# Copyright 2023 The MediaPipe Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package(default_visibility = ["//mediapipe/tasks:internal"]) + +licenses(["notice"]) + +objc_library( + name = "MPPHandLandmarkerResult", + srcs = ["sources/MPPHandLandmarkerResult.m"], + hdrs = ["sources/MPPHandLandmarkerResult.h"], + deps = [ + "//mediapipe/tasks/ios/components/containers:MPPCategory", + "//mediapipe/tasks/ios/components/containers:MPPLandmark", + "//mediapipe/tasks/ios/core:MPPTaskResult", + ], +) + diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h new file mode 100644 index 000000000..5291e5294 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h @@ -0,0 +1,56 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +#import "mediapipe/tasks/ios/components/containers/sources/MPPCategory.h" +#import "mediapipe/tasks/ios/components/containers/sources/MPPLandmark.h" +#import "mediapipe/tasks/ios/core/sources/MPPTaskResult.h" + +NS_ASSUME_NONNULL_BEGIN + +/** Represents the hand landmarker results generated by MPPHandLandmarker. */ +NS_SWIFT_NAME(HandLandmarkerResult) +@interface MPPHandLandmarkerResult : MPPTaskResult + +/** Hand landmarks of detected hands. */ +@property(nonatomic, readonly) NSArray *> *landmarks; + +/** Hand landmarks in world coordniates of detected hands. */ +@property(nonatomic, readonly) NSArray *> *worldLandmarks; + +/** Handedness of detected hands. */ +@property(nonatomic, readonly) NSArray *> *handedness; + +/** + * Initializes a new `MPPGestureRecognizerResult` with the given landmarks, world landmarks, + * handedness, gestures and timestamp (in milliseconds). + * + * @param landmarks The hand landmarks of detected hands. + * @param worldLandmarks The hand landmarks in world coordniates of detected hands. + * @param handedness The handedness of detected hands. + * @param timestampInMilliseconds The timestamp for this result. + * + * @return An instance of `MPPGestureRecognizerResult` initialized with the given landmarks, world + * landmarks, handedness and gestures. + * + */ +- (instancetype)initWithLandmarks:(NSArray *> *)landmarks + worldLandmarks:(NSArray *> *)worldLandmarks + handedness:(NSArray *> *)handedness + timestampInMilliseconds:(NSInteger)timestampInMilliseconds; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.m b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.m new file mode 100644 index 000000000..bc15550e3 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.m @@ -0,0 +1,32 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h" + +@implementation MPPHandLandmarkerResult + +- (instancetype)initWithLandmarks:(NSArray *> *)landmarks + worldLandmarks:(NSArray *> *)worldLandmarks + handedness:(NSArray *> *)handedness + timestampInMilliseconds:(NSInteger)timestampInMilliseconds { + self = [super initWithTimestampInMilliseconds:timestampInMilliseconds]; + if (self) { + _landmarks = landmarks; + _worldLandmarks = worldLandmarks; + _handedness = handedness; + } + return self; +} + +@end From 5ad7c9fd89c463a065208f4872d21e03ab9f1955 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 10:58:12 +0530 Subject: [PATCH 2/9] Added iOS hand landmarker options --- .../tasks/ios/vision/hand_landmarker/BUILD | 10 ++ .../sources/MPPHandLandmarkerOptions.h | 98 +++++++++++++++++++ .../sources/MPPHandLandmarkerOptions.m | 43 ++++++++ 3 files changed, 151 insertions(+) create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.m diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/BUILD b/mediapipe/tasks/ios/vision/hand_landmarker/BUILD index 62ad4d4d0..2665142af 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/BUILD +++ b/mediapipe/tasks/ios/vision/hand_landmarker/BUILD @@ -27,3 +27,13 @@ objc_library( ], ) +objc_library( + name = "MPPHandLandmarkerOptions", + srcs = ["sources/MPPHandLandmarkerOptions.m"], + hdrs = ["sources/MPPHandLandmarkerOptions.h"], + deps = [ + ":MPPHandLandmarkerResult", + "//mediapipe/tasks/ios/core:MPPTaskOptions", + "//mediapipe/tasks/ios/vision/core:MPPRunningMode", + ], +) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h new file mode 100644 index 000000000..27fdac2d8 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h @@ -0,0 +1,98 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +#import "mediapipe/tasks/ios/core/sources/MPPTaskOptions.h" +#import "mediapipe/tasks/ios/vision/core/sources/MPPRunningMode.h" +#import "mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h" + +NS_ASSUME_NONNULL_BEGIN + +@class MPPHandLandmarker; + +/** + * This protocol defines an interface for the delegates of `MPPHandLandmarker` object to receive + * results of performing asynchronous hand landmark detection on images (i.e, when `runningMode` = `MPPRunningModeLiveStream`). + * + * The delegate of `MPPHandLandmarker` must adopt `MPPHandLandmarkerLiveStreamDelegate` protocol. + * The methods in this protocol are optional. + */ +NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate) +@protocol MPPHandLandmarkerLiveStreamDelegate + +@optional + +/** + * This method notifies a delegate that the results of asynchronous hand landmark detection of an image submitted to the `MPPHandLandmarker` is available. + * + * This method is called on a private serial dispatch queue created by the `MPPHandLandmarker` + * for performing the asynchronous delegates calls. + * + * @param handLandmarker The hand landmarker which performed the hand landmarking. + * This is useful to test equality when there are multiple instances of `MPPHandLandmarker`. + * @param result The `MPPHandLandmarkerResult` object that contains a list of detections, each + * 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 + * underlying image data. + * @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input + * image was sent to the hand landmarker. + * @param error An optional error parameter populated when there is an error in performing hand landmark detection on the input live stream image data. + */ +- (void)handLandmarker:(MPPHandLandmarker *)handLandmarker + didFinishDetectionWithResult:(nullable MPPHandLandmarkerResult *)result + timestampInMilliseconds:(NSInteger)timestampInMilliseconds + error:(nullable NSError *)error + NS_SWIFT_NAME(handLandmarker(_:didFinishDetection:timestampInMilliseconds:error:)); +@end + +/** Options for setting up a `MPPHandLandmarker`. */ +NS_SWIFT_NAME(HandLandmarkerOptions) +@interface MPPHandLandmarkerOptions : MPPTaskOptions + +/** + * Running mode of the hand landmarker task. Defaults to `MPPRunningModeImage`. + * `MPPHandLandmarker` can be created with one of the following running modes: + * 1. `MPPRunningModeImage`: The mode for performing hand landmark detection on single image inputs. + * 2. `MPPRunningModeVideo`: The mode for performing hand landmark detection on the decoded frames of a + * video. + * 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; + +/** + * An object that confirms to `MPPHandLandmarkerLiveStreamDelegate` protocol. This object must + * implement `handLandmarker:didFinishDetectionWithResult:timestampInMilliseconds:error:` to + * receive the results of performing asynchronous gesture recognition on images (i.e, when + * `runningMode` = `MPPRunningModeLiveStream`). + */ +@property(nonatomic, weak, nullable) id + handLandmarkerLiveStreamDelegate; + +/** The maximum number of hands that can be detected by the `MPPHandLandmarker`. */ +@property(nonatomic) NSInteger numHands; + +/** The minimum confidence score for the hand detection to be considered successful. */ +@property(nonatomic) float minHandDetectionConfidence; + +/** The minimum confidence score of hand presence score in the hand landmark detection. */ +@property(nonatomic) float minHandPresenceConfidence; + +/** The minimum confidence score for the hand tracking to be considered successful. */ +@property(nonatomic) float minTrackingConfidence; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.m b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.m new file mode 100644 index 000000000..d7b4a0252 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.m @@ -0,0 +1,43 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h" + +@implementation MPPHandLandmarkerOptions + +- (instancetype)init { + self = [super init]; + if (self) { + _numHands = 1; + _minHandDetectionConfidence = 0.5f; + _minHandPresenceConfidence = 0.5f; + _minTrackingConfidence = 0.5f; + } + return self; +} + +- (id)copyWithZone:(NSZone *)zone { + MPPHandLandmarkerOptions *handLandmarkerOptions = [super copyWithZone:zone]; + + handLandmarkerOptions.runningMode = self.runningMode; + handLandmarkerOptions.handLandmarkerLiveStreamDelegate = self.handLandmarkerLiveStreamDelegate; + handLandmarkerOptions.numHands = self.numHands; + handLandmarkerOptions.minHandDetectionConfidence = self.minHandDetectionConfidence; + handLandmarkerOptions.minHandPresenceConfidence = self.minHandPresenceConfidence; + handLandmarkerOptions.minTrackingConfidence = self.minTrackingConfidence; + + return handLandmarkerOptions; +} + +@end From ddf4d3fbd3e612ed6beb8c4cb3a77565c7baa184 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 10:58:30 +0530 Subject: [PATCH 3/9] Added iOS hand landmarker options helpers --- .../ios/vision/hand_landmarker/utils/BUILD | 33 ++++++++++ .../MPPHandLandmarkerOptions+Helpers.h | 32 ++++++++++ .../MPPHandLandmarkerOptions+Helpers.mm | 60 +++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/utils/BUILD create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.h create mode 100644 mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/utils/BUILD b/mediapipe/tasks/ios/vision/hand_landmarker/utils/BUILD new file mode 100644 index 000000000..dfb85a218 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/utils/BUILD @@ -0,0 +1,33 @@ +# Copyright 2023 The MediaPipe Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package(default_visibility = ["//mediapipe/tasks:internal"]) + +licenses(["notice"]) + +objc_library( + name = "MPPHandLandmarkerOptionsHelpers", + srcs = ["sources/MPPHandLandmarkerOptions+Helpers.mm"], + hdrs = ["sources/MPPHandLandmarkerOptions+Helpers.h"], + deps = [ + "//mediapipe/framework:calculator_options_cc_proto", + "//mediapipe/tasks/cc/vision/hand_detector/proto:hand_detector_graph_options_cc_proto", + "//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_cc_proto", + "//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_cc_proto", + "//mediapipe/tasks/ios/common/utils:NSStringHelpers", + "//mediapipe/tasks/ios/core:MPPTaskOptionsProtocol", + "//mediapipe/tasks/ios/core/utils:MPPBaseOptionsHelpers", + "//mediapipe/tasks/ios/vision/hand_landmarker:MPPHandLandmarkerOptions", + ], +) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.h b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.h new file mode 100644 index 000000000..d93f43507 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.h @@ -0,0 +1,32 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "mediapipe/framework/calculator_options.pb.h" +#import "mediapipe/tasks/ios/core/sources/MPPTaskOptionsProtocol.h" +#import "mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MPPHandLandmarkerOptions (Helpers) + +/** + * Populates the provided `CalculatorOptions` proto container with the current settings. + * + * @param optionsProto The `CalculatorOptions` proto object to copy the settings to. + */ +- (void)copyToProto:(::mediapipe::CalculatorOptions *)optionsProto; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm new file mode 100644 index 000000000..f88a35bc8 --- /dev/null +++ b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm @@ -0,0 +1,60 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.h" + +#import "mediapipe/tasks/ios/common/utils/sources/NSString+Helpers.h" +#import "mediapipe/tasks/ios/core/utils/sources/MPPBaseOptions+Helpers.h" + +#include "mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_graph_options.pb.h" +#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_graph_options.pb.h" +#include "mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options.pb.h" + +namespace { +using CalculatorOptionsProto = mediapipe::CalculatorOptions; +using HandLandmarkerGraphOptionsProto = + ::mediapipe::tasks::vision::hand_landmarker::proto::HandLandmarkerGraphOptions; +using HandDetectorGraphOptionsProto = + ::mediapipe::tasks::vision::hand_detector::proto::HandDetectorGraphOptions; +using HandLandmarksDetectorGraphOptionsProto = + ::mediapipe::tasks::vision::hand_landmarker::proto::HandLandmarksDetectorGraphOptions; +} // namespace + +@implementation MPPHandLandmarkerOptions (Helpers) + +- (void)copyToProto:(CalculatorOptionsProto *)optionsProto { + HandLandmarkerGraphOptionsProto *handLandmarkerGraphOptionsProto = + optionsProto + ->MutableExtension(HandLandmarkerGraphOptionsProto::ext) + handLandmarkerGraphOptionsProto->Clear(); + + [self.baseOptions copyToProto:gestureRecognizerGraphOptionsProto->mutable_base_options() + withUseStreamMode:self.runningMode != MPPRunningModeImage]; + + handLandmarkerGraphOptionsProto->set_min_tracking_confidence(self.minTrackingConfidence); + + HandDetectorGraphOptionsProto *handDetectorGraphOptionsProto = + handLandmarkerGraphOptionsProto->mutable_hand_detector_graph_options(); + handDetectorGraphOptionsProto->Clear(); + handDetectorGraphOptionsProto->set_num_hands(self.numberOfHands); + handDetectorGraphOptionsProto->set_min_detection_confidence(self.minHandDetectionConfidence); + + HandLandmarksDetectorGraphOptionsProto *handLandmarksDetectorGraphOptionsProto = + handLandmarkerGraphOptionsProto->mutable_hand_landmarks_detector_graph_options(); + handLandmarksDetectorGraphOptionsProto->Clear(); + handLandmarksDetectorGraphOptionsProto->set_min_detection_confidence( + self.minHandPresenceConfidence); +} + +@end From b442367fc97530354b8ad7b3d1168c451df72530 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 20:57:13 +0530 Subject: [PATCH 4/9] Fixed formatting --- .../sources/MPPHandLandmarkerOptions.h | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h index 27fdac2d8..0b370f802 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h @@ -24,7 +24,8 @@ NS_ASSUME_NONNULL_BEGIN /** * This protocol defines an interface for the delegates of `MPPHandLandmarker` object to receive - * results of performing asynchronous hand landmark detection on images (i.e, when `runningMode` = `MPPRunningModeLiveStream`). + * results of performing asynchronous hand landmark detection on images (i.e, when `runningMode` = + * `MPPRunningModeLiveStream`). * * The delegate of `MPPHandLandmarker` must adopt `MPPHandLandmarkerLiveStreamDelegate` protocol. * The methods in this protocol are optional. @@ -35,7 +36,8 @@ NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate) @optional /** - * This method notifies a delegate that the results of asynchronous hand landmark detection of an image submitted to the `MPPHandLandmarker` is available. + * This method notifies a delegate that the results of asynchronous hand landmark detection of an + * image submitted to the `MPPHandLandmarker` is available. * * This method is called on a private serial dispatch queue created by the `MPPHandLandmarker` * for performing the asynchronous delegates calls. @@ -48,7 +50,8 @@ NS_SWIFT_NAME(HandLandmarkerLiveStreamDelegate) * underlying image data. * @param timestampInMilliseconds The timestamp (in milliseconds) which indicates when the input * image was sent to the hand landmarker. - * @param error An optional error parameter populated when there is an error in performing hand landmark detection on the input live stream image data. + * @param error An optional error parameter populated when there is an error in performing hand + * landmark detection on the input live stream image data. */ - (void)handLandmarker:(MPPHandLandmarker *)handLandmarker didFinishDetectionWithResult:(nullable MPPHandLandmarkerResult *)result @@ -64,11 +67,12 @@ NS_SWIFT_NAME(HandLandmarkerOptions) /** * Running mode of the hand landmarker task. Defaults to `MPPRunningModeImage`. * `MPPHandLandmarker` can be created with one of the following running modes: - * 1. `MPPRunningModeImage`: The mode for performing hand landmark detection on single image inputs. - * 2. `MPPRunningModeVideo`: The mode for performing hand landmark detection on the decoded frames of a - * video. - * 3. `MPPRunningModeLiveStream`: The mode for performing hand landmark detection on a live stream of - * input data, such as from the camera. + * 1. `MPPRunningModeImage`: The mode for performing hand landmark detection on single image + * inputs. + * 2. `MPPRunningModeVideo`: The mode for performing hand landmark detection on the decoded frames + * of a video. + * 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; From ff064e536c5dce58f1fff9d3c74dbd73705c11ec Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 20:57:32 +0530 Subject: [PATCH 5/9] Added new line --- .../vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h index 0b370f802..b7901b2c3 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h @@ -99,4 +99,4 @@ NS_SWIFT_NAME(HandLandmarkerOptions) @end -NS_ASSUME_NONNULL_END \ No newline at end of file +NS_ASSUME_NONNULL_END From bec7aeec224fbfde862cd0b31c6167daa7ac1513 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 20:59:13 +0530 Subject: [PATCH 6/9] Fixed typo in MPPHandLandmarkerOptions --- .../vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h index b7901b2c3..4da78ecc1 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerOptions.h @@ -79,7 +79,7 @@ NS_SWIFT_NAME(HandLandmarkerOptions) /** * An object that confirms to `MPPHandLandmarkerLiveStreamDelegate` protocol. This object must * implement `handLandmarker:didFinishDetectionWithResult:timestampInMilliseconds:error:` to - * receive the results of performing asynchronous gesture recognition on images (i.e, when + * receive the results of performing asynchronous hand landmark detection on images (i.e, when * `runningMode` = `MPPRunningModeLiveStream`). */ @property(nonatomic, weak, nullable) id From 881c6e2eeff48c119968ace4bdace9eb170de4fb Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 21:00:59 +0530 Subject: [PATCH 7/9] Fixed typo in MPPHandLandmarkerResult --- .../hand_landmarker/sources/MPPHandLandmarkerResult.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h index 5291e5294..238aa406a 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarkerResult.h @@ -34,16 +34,16 @@ NS_SWIFT_NAME(HandLandmarkerResult) @property(nonatomic, readonly) NSArray *> *handedness; /** - * Initializes a new `MPPGestureRecognizerResult` with the given landmarks, world landmarks, - * handedness, gestures and timestamp (in milliseconds). + * Initializes a new `MPPHandLandmarkerResult` with the given landmarks, world landmarks, + * handedness and timestamp (in milliseconds). * * @param landmarks The hand landmarks of detected hands. * @param worldLandmarks The hand landmarks in world coordniates of detected hands. * @param handedness The handedness of detected hands. * @param timestampInMilliseconds The timestamp for this result. * - * @return An instance of `MPPGestureRecognizerResult` initialized with the given landmarks, world - * landmarks, handedness and gestures. + * @return An instance of `MPPGHandLandmarkerResult` initialized with the given landmarks, world + * landmarks, handedness and timestamp (in milliseconds). * */ - (instancetype)initWithLandmarks:(NSArray *> *)landmarks From 2428ba49a3231351dae9b1437fb2ef087f62f55e Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 21:02:14 +0530 Subject: [PATCH 8/9] Fixed typo in MPPHandLandmarkerOptions --- .../utils/sources/MPPHandLandmarkerOptions+Helpers.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm index f88a35bc8..718698698 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm +++ b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm @@ -39,7 +39,7 @@ using HandLandmarksDetectorGraphOptionsProto = ->MutableExtension(HandLandmarkerGraphOptionsProto::ext) handLandmarkerGraphOptionsProto->Clear(); - [self.baseOptions copyToProto:gestureRecognizerGraphOptionsProto->mutable_base_options() + [self.baseOptions copyToProto:handLandmarkerGraphOptionsProto->mutable_base_options() withUseStreamMode:self.runningMode != MPPRunningModeImage]; handLandmarkerGraphOptionsProto->set_min_tracking_confidence(self.minTrackingConfidence); From 41d0f89fd1c62d2336397bac3356b354a3e13dea Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 26 May 2023 21:06:29 +0530 Subject: [PATCH 9/9] Updated variable names in MPPHandLandmarkerOptionsHelpers --- .../utils/sources/MPPHandLandmarkerOptions+Helpers.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm index 718698698..61061f6e9 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm +++ b/mediapipe/tasks/ios/vision/hand_landmarker/utils/sources/MPPHandLandmarkerOptions+Helpers.mm @@ -36,7 +36,7 @@ using HandLandmarksDetectorGraphOptionsProto = - (void)copyToProto:(CalculatorOptionsProto *)optionsProto { HandLandmarkerGraphOptionsProto *handLandmarkerGraphOptionsProto = optionsProto - ->MutableExtension(HandLandmarkerGraphOptionsProto::ext) + ->MutableExtension(HandLandmarkerGraphOptionsProto::ext); handLandmarkerGraphOptionsProto->Clear(); [self.baseOptions copyToProto:handLandmarkerGraphOptionsProto->mutable_base_options() @@ -47,7 +47,7 @@ using HandLandmarksDetectorGraphOptionsProto = HandDetectorGraphOptionsProto *handDetectorGraphOptionsProto = handLandmarkerGraphOptionsProto->mutable_hand_detector_graph_options(); handDetectorGraphOptionsProto->Clear(); - handDetectorGraphOptionsProto->set_num_hands(self.numberOfHands); + handDetectorGraphOptionsProto->set_num_hands(self.numHands); handDetectorGraphOptionsProto->set_min_detection_confidence(self.minHandDetectionConfidence); HandLandmarksDetectorGraphOptionsProto *handLandmarksDetectorGraphOptionsProto =