Added iOS hand landmarker options helpers
This commit is contained in:
parent
5ad7c9fd89
commit
ddf4d3fbd3
33
mediapipe/tasks/ios/vision/hand_landmarker/utils/BUILD
Normal file
33
mediapipe/tasks/ios/vision/hand_landmarker/utils/BUILD
Normal file
|
@ -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",
|
||||||
|
],
|
||||||
|
)
|
|
@ -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) <MPPTaskOptionsProtocol>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user