From 9421249de18b7d33415d74694b61063a99101c6f Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Mon, 3 Apr 2023 20:07:45 +0530 Subject: [PATCH 1/5] Added MPPDetection --- .../tasks/ios/components/containers/BUILD | 7 ++ .../containers/sources/MPPDetection.h | 100 ++++++++++++++++++ .../containers/sources/MPPDetection.m | 70 ++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 mediapipe/tasks/ios/components/containers/sources/MPPDetection.h create mode 100644 mediapipe/tasks/ios/components/containers/sources/MPPDetection.m diff --git a/mediapipe/tasks/ios/components/containers/BUILD b/mediapipe/tasks/ios/components/containers/BUILD index 36c8ef2e0..06df9576a 100644 --- a/mediapipe/tasks/ios/components/containers/BUILD +++ b/mediapipe/tasks/ios/components/containers/BUILD @@ -44,3 +44,10 @@ objc_library( hdrs = ["sources/MPPEmbeddingResult.h"], deps = [":MPPEmbedding"], ) + +objc_library( + name = "MPPDetection", + srcs = ["sources/MPPDetection.m"], + hdrs = ["sources/MPPDetection.h"], + deps = [":MPPCategory"], +) diff --git a/mediapipe/tasks/ios/components/containers/sources/MPPDetection.h b/mediapipe/tasks/ios/components/containers/sources/MPPDetection.h new file mode 100644 index 000000000..cc7c2ebeb --- /dev/null +++ b/mediapipe/tasks/ios/components/containers/sources/MPPDetection.h @@ -0,0 +1,100 @@ +// 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" + +NS_ASSUME_NONNULL_BEGIN + +/** + * Normalized keypoint represents a point in 2D space with x, y coordinates. x and y are normalized + * to [0.0, 1.0] by the image width and height respectively. + */ +NS_SWIFT_NAME(NormalizedKeypoint) +@interface MPPNormalizedKeypoint : NSObject + +/** The (x,y) coordinates location of the normalized keypoint. */ +@property(nonatomic, readonly) CGPoint location; + +/** The optional label of the normalized keypoint. */ +@property(nonatomic, readonly, nullable) NSString *label; + +/** The optional score of the normalized keypoint. If score is absent, it will be equal to 0.0. */ +@property(nonatomic, readonly) float score; + +/** + * Initializes a new `MPPNormalizedKeypoint` object with the given location, label and score. + * You must pass 0.0 for `score` if it is not present. + * + * @param location The (x,y) coordinates location of the normalized keypoint. + * @param label The optional label of the normalized keypoint. + * @param score The optional score of the normalized keypoint. You must pass 0.0 for score if it + * is not present. + * + * @return An instance of `MPPNormalizedKeypoint` initialized with the given given location, label + * and score. + */ +- (instancetype)initWithLocation:(CGPoint)location + label:(nullable NSString *)label + score:(float)score NS_DESIGNATED_INITIALIZER; + +- (instancetype)init NS_UNAVAILABLE; + ++ (instancetype)new NS_UNAVAILABLE; + +@end + +/** Represents one detected object in the results of `MPPObjectDetector`. */ +NS_SWIFT_NAME(Detection) +@interface MPPDetection : NSObject + +/** An array of `MPPCategory` objects containing the predicted categories. */ +@property(nonatomic, readonly) NSArray *categories; + +/** The bounding box of the detected object. */ +@property(nonatomic, readonly) CGRect boundingBox; + +/** An optional array of `MPPNormalizedKeypoint` objects associated with the detection. Keypoints + * represent interesting points related to the detection. For example, the keypoints represent the + * eyes, ear and mouth from face detection model. Or in the template matching detection, e.g. KNIFT, + * they can represent the feature points for template matching. */ +@property(nonatomic, readonly, nullable) NSArray *keypoints; + +/** + * Initializes a new `MPPDetection` object with the given array of categories, bounding box and + * optional array of keypoints; + * + * @param categories A list of `MPPCategory` objects that contain category name, display name, + * score, and the label index. + * @param boundingBox A `CGRect` that represents the bounding box. + * @param keypoints: An optional array of `MPPNormalizedKeypoint` objects associated with the + * detection. Keypoints represent interesting points related to the detection. For example, the + * keypoints represent the eyes, ear and mouth from face detection model. Or in the template + * matching detection, e.g. KNIFT, they can represent the feature points for template matching. + * + * @return An instance of `MPPDetection` initialized with the given array of categories, bounding + * box and `nil` keypoints. + */ +- (instancetype)initWithCategories:(NSArray *)categories + boundingBox:(CGRect)boundingBox + keypoints:(nullable NSArray *)keypoints + NS_DESIGNATED_INITIALIZER; + +- (instancetype)init NS_UNAVAILABLE; + ++ (instancetype)new NS_UNAVAILABLE; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m b/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m new file mode 100644 index 000000000..42259ffde --- /dev/null +++ b/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m @@ -0,0 +1,70 @@ +// 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/components/containers/sources/MPPDetection.h" + +@implementation MPPNormalizedKeypoint + +- (instancetype)initWithLocation:(CGPoint)location + label:(nullable NSString *)label + score:(float)score { + self = [super init]; + if (self) { + _location = location; + _label = label; + _score = score; + } + return self; +} + +// TODO: Implement hash + +- (BOOL)isEqual:(nullable id)object { + if (!object) { + return NO; + } + + if (self == object) { + return YES; + } + + if (![object isKindOfClass:[MPPNormalizedKeypoint class]]) { + return NO; + } + + MPPNormalizedKeypoint *otherKeypoint = (MPPNormalizedKeypoint *)object; + + if (CGPointEqualToPoint(self.location, otherKeypoint.location) && + (self.label == otherKeypoint.label) && (self.score == otherKeypoint.score)) { + return YES; + } +} + +@end + +@implementation MPPDetection + +- (instancetype)initWithCategories:(NSArray *)categories + boundingBox:(CGRect)boundingBox + keypoints:(nullable NSArray *)keypoints { + self = [super init]; + if (self) { + _categories = categories; + _boundingBox = boundingBox; + _keypoints = keypoints; + } + return self; +} + +@end \ No newline at end of file From 4943029d62d42b26eeb4589b0d963b853f69e98d Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Mon, 3 Apr 2023 20:11:44 +0530 Subject: [PATCH 2/5] Added MPPDetectionHelpers --- .../ios/components/containers/utils/BUILD | 11 +++ .../utils/sources/MPPDetection+Helpers.h | 26 ++++++ .../utils/sources/MPPDetection+Helpers.mm | 82 +++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.h create mode 100644 mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.mm diff --git a/mediapipe/tasks/ios/components/containers/utils/BUILD b/mediapipe/tasks/ios/components/containers/utils/BUILD index 64ca29b88..3520740b0 100644 --- a/mediapipe/tasks/ios/components/containers/utils/BUILD +++ b/mediapipe/tasks/ios/components/containers/utils/BUILD @@ -61,3 +61,14 @@ objc_library( "//mediapipe/tasks/ios/components/containers:MPPEmbeddingResult", ], ) + +objc_library( + name = "MPPDetectionHelpers", + srcs = ["sources/MPPDetection+Helpers.mm"], + hdrs = ["sources/MPPDetection+Helpers.h"], + deps = [ + "//mediapipe/framework/formats:detection_cc_proto", + "//mediapipe/tasks/ios/common/utils:NSStringHelpers", + "//mediapipe/tasks/ios/components/containers:MPPDetection", + ], +) diff --git a/mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.h b/mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.h new file mode 100644 index 000000000..c06c04d3e --- /dev/null +++ b/mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.h @@ -0,0 +1,26 @@ +// 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/formats/detection.pb.h" +#import "mediapipe/tasks/ios/components/containers/sources/MPPDetection.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MPPDetection (Helpers) + ++ (MPPDetection *)detectionWithProto:(const mediapipe::Detection &)detectionProto; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.mm b/mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.mm new file mode 100644 index 000000000..e5cc8dc03 --- /dev/null +++ b/mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.mm @@ -0,0 +1,82 @@ +// 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/components/containers/utils/sources/MPPDetection+Helpers.h" + +#import "mediapipe/tasks/ios/common/utils/sources/NSString+Helpers.h" + +static const NSInteger kDefaultCategoryIndex = -1; + +namespace { +using DetectionProto = ::mediapipe::Detection; +using BoundingBoxProto = ::mediapipe::LocationData::BoundingBox; +} // namespace + +@implementation MPPDetection (Helpers) + ++ (MPPDetection *)detectionWithProto:(const DetectionProto &)detectionProto { + NSMutableArray *categories = + [NSMutableArray arrayWithCapacity:(NSUInteger)detectionProto.score_size()]; + + for (int idx = 0; idx < detectionProto.score_size(); ++idx) { + NSInteger categoryIndex = + detectionProto.label_id_size() > idx ? detectionProto.label_id(idx) : kDefaultCategoryIndex; + NSString *categoryName = detectionProto.label_size() > idx + ? [NSString stringWithCppString:detectionProto.label(idx)] + : nil; + + NSString *displayName = detectionProto.display_name_size() > idx + ? [NSString stringWithCppString:detectionProto.display_name(idx)] + : nil; + + [categories addObject:[[MPPCategory alloc] initWithIndex:categoryIndex + score:detectionProto.score(idx) + categoryName:categoryName + displayName:displayName]]; + } + + CGRect boundingBox = CGRectZero; + + if (detectionProto.location_data().has_bounding_box()) { + const BoundingBoxProto &boundingBoxProto = detectionProto.location_data().bounding_box(); + boundingBox.origin.x = boundingBoxProto.xmin(); + boundingBox.origin.y = boundingBoxProto.ymin(); + boundingBox.size.width = boundingBoxProto.width(); + boundingBox.size.height = boundingBoxProto.height(); + } + + NSMutableArray *normalizedKeypoints; + + if (!detectionProto.location_data().relative_keypoints().empty()) { + normalizedKeypoints = [NSMutableArray + arrayWithCapacity:(NSUInteger)detectionProto.location_data().relative_keypoints_size()]; + for (const auto &keypoint : detectionProto.location_data().relative_keypoints()) { + NSString *label = keypoint.has_keypoint_label() + ? [NSString stringWithCppString:keypoint.keypoint_label()] + : nil; + CGPoint location = CGPointMake(keypoint.x(), keypoint.y()); + float score = keypoint.has_score() ? keypoint.score() : 0.0f; + + [normalizedKeypoints addObject:[[MPPNormalizedKeypoint alloc] initWithLocation:location + label:label + score:score]]; + } + } + + return [[MPPDetection alloc] initWithCategories:categories + boundingBox:boundingBox + keypoints:normalizedKeypoints]; +} + +@end From 67fcf9196eaf7e8a3f0369fd4c09234b58300583 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Mon, 3 Apr 2023 20:14:26 +0530 Subject: [PATCH 3/5] Added MPPObjectDetectionResult --- .../tasks/ios/vision/object_detector/BUILD | 28 +++++++++++ .../sources/MPPObjectDetectionResult.h | 47 +++++++++++++++++++ .../sources/MPPObjectDetectionResult.m | 28 +++++++++++ 3 files changed, 103 insertions(+) create mode 100644 mediapipe/tasks/ios/vision/object_detector/BUILD create mode 100644 mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.h create mode 100644 mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.m diff --git a/mediapipe/tasks/ios/vision/object_detector/BUILD b/mediapipe/tasks/ios/vision/object_detector/BUILD new file mode 100644 index 000000000..218e1a8cc --- /dev/null +++ b/mediapipe/tasks/ios/vision/object_detector/BUILD @@ -0,0 +1,28 @@ +# Copyright 2023 The MediaPipe Authors. All Rights Reserved. +# +# 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 = "MPPObjectDetectionResult", + srcs = ["sources/MPPObjectDetectionResult.m"], + hdrs = ["sources/MPPObjectDetectionResult.h"], + deps = [ + "//mediapipe/tasks/ios/components/containers:MPPDetection", + "//mediapipe/tasks/ios/core:MPPTaskResult", + ], +) + diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.h b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.h new file mode 100644 index 000000000..6e4921efc --- /dev/null +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.h @@ -0,0 +1,47 @@ +// 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/MPPDetection.h" +#import "mediapipe/tasks/ios/core/sources/MPPTaskResult.h" + +NS_ASSUME_NONNULL_BEGIN + +/** Represents the detection results generated by `MPPObjectDetector`. */ +NS_SWIFT_NAME(ObjectDetectionResult) +@interface MPPObjectDetectionResult : MPPTaskResult + +/** The array of `MPPDetection` objects each of which 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. */ +@property(nonatomic, readonly) NSArray *detections; + +/** + * Initializes a new `MPPObjectDetectionResult` with the given array of detections and timestamp (in + * milliseconds). + * + * @param detections An array of `MPPDetection` objects each of which 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 timestampMs The timestamp for this result. + * + * @return An instance of `MPPObjectDetectionResult` initialized with the given array of detections + * and timestamp (in milliseconds). + */ +- (instancetype)initWithDetections:(NSArray *)detections + timestampMs:(NSInteger)timestampMs; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.m b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.m new file mode 100644 index 000000000..ac24c19fa --- /dev/null +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectionResult.m @@ -0,0 +1,28 @@ +// 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/object_detector/sources/MPPObjectDetectionResult.h" + +@implementation MPPObjectDetectionResult + +- (instancetype)initWithDetections:(NSArray *)detections + timestampMs:(NSInteger)timestampMs { + self = [super initWithTimestampMs:timestampMs]; + if (self) { + _detections = detections; + } + return self; +} + +@end From 1ab9b138efe76cd10e041662fe6e5c33cd42c86e Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Mon, 3 Apr 2023 20:14:41 +0530 Subject: [PATCH 4/5] Added MPPObjectDetectorOptions --- .../tasks/ios/vision/object_detector/BUILD | 10 +++ .../sources/MPPObjectDetectorOptions.h | 71 +++++++++++++++++++ .../sources/MPPObjectDetectorOptions.m | 41 +++++++++++ 3 files changed, 122 insertions(+) create mode 100644 mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.h create mode 100644 mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.m diff --git a/mediapipe/tasks/ios/vision/object_detector/BUILD b/mediapipe/tasks/ios/vision/object_detector/BUILD index 218e1a8cc..f1325b050 100644 --- a/mediapipe/tasks/ios/vision/object_detector/BUILD +++ b/mediapipe/tasks/ios/vision/object_detector/BUILD @@ -26,3 +26,13 @@ objc_library( ], ) +objc_library( + name = "MPPObjectDetectorOptions", + srcs = ["sources/MPPObjectDetectorOptions.m"], + hdrs = ["sources/MPPObjectDetectorOptions.h"], + deps = [ + ":MPPObjectDetectionResult", + "//mediapipe/tasks/ios/core:MPPTaskOptions", + "//mediapipe/tasks/ios/vision/core:MPPRunningMode", + ], +) diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.h b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.h new file mode 100644 index 000000000..bf92e9a44 --- /dev/null +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.h @@ -0,0 +1,71 @@ +// 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/object_detector/sources/MPPObjectDetectionResult.h" + +NS_ASSUME_NONNULL_BEGIN + +/** Options for setting up a `MPPObjectDetector`. */ +NS_SWIFT_NAME(ObjectDetectorOptions) +@interface MPPObjectDetectorOptions : MPPTaskOptions + +@property(nonatomic) MPPRunningMode runningMode; + +/** + * The user-defined result callback for processing live stream data. The result callback should only + * be specified when the running mode is set to the live stream mode. + * TODO: Add parameter `MPPImage` in the callback. + */ +@property(nonatomic, copy) void (^completion) + (MPPObjectDetectionResult *result, NSInteger timestampMs, NSError *error); + +/** + * The locale to use for display names specified through the TFLite Model Metadata, if any. Defaults + * to English. + */ +@property(nonatomic, copy) NSString *displayNamesLocale; + +/** + * The maximum number of top-scored classification results to return. If < 0, all available results + * will be returned. If 0, an invalid argument error is returned. + */ +@property(nonatomic) NSInteger maxResults; + +/** + * Score threshold to override the one provided in the model metadata (if any). Results below this + * value are rejected. + */ +@property(nonatomic) float scoreThreshold; + +/** + * The allowlist of category names. If non-empty, detection results whose category name is not in + * this set will be filtered out. Duplicate or unknown category names are ignored. Mutually + * exclusive with categoryDenylist. + */ +@property(nonatomic, copy) NSArray *categoryAllowlist; + +/** + * The denylist of category names. If non-empty, detection results whose category name is in this + * set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive + * with categoryAllowlist. + */ +@property(nonatomic, copy) NSArray *categoryDenylist; + +@end + +NS_ASSUME_NONNULL_END diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.m b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.m new file mode 100644 index 000000000..73f8ce5b5 --- /dev/null +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetectorOptions.m @@ -0,0 +1,41 @@ +// 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/object_detector/sources/MPPObjectDetectorOptions.h" + +@implementation MPPObjectDetectorOptions + +- (instancetype)init { + self = [super init]; + if (self) { + _maxResults = -1; + _scoreThreshold = 0; + } + return self; +} + +- (id)copyWithZone:(NSZone *)zone { + MPPObjectDetectorOptions *objectDetectorOptions = [super copyWithZone:zone]; + + objectDetectorOptions.scoreThreshold = self.scoreThreshold; + objectDetectorOptions.maxResults = self.maxResults; + objectDetectorOptions.categoryDenylist = self.categoryDenylist; + objectDetectorOptions.categoryAllowlist = self.categoryAllowlist; + objectDetectorOptions.displayNamesLocale = self.displayNamesLocale; + objectDetectorOptions.completion = self.completion; + + return objectDetectorOptions; +} + +@end From 048cc51e136dc5d2f3a4839ad0ea4c2422593c7b Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Mon, 3 Apr 2023 20:15:35 +0530 Subject: [PATCH 5/5] Added new line --- .../tasks/ios/components/containers/sources/MPPDetection.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m b/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m index 42259ffde..a4dd642e2 100644 --- a/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m +++ b/mediapipe/tasks/ios/components/containers/sources/MPPDetection.m @@ -67,4 +67,4 @@ return self; } -@end \ No newline at end of file +@end