From 117bb507e6225e3aadf9f176cc9d0049bdaa33e1 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Wed, 24 May 2023 19:17:20 +0530 Subject: [PATCH] Updated iOS vision tasks to use new methods from vision task runner --- .../sources/MPPImageClassifier.mm | 18 ++++++++---------- .../sources/MPPObjectDetector.mm | 8 ++------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm b/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm index 3ad8d0ded..10f6fc267 100644 --- a/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm +++ b/mediapipe/tasks/ios/vision/image_classifier/sources/MPPImageClassifier.mm @@ -166,10 +166,9 @@ static const int kMicroSecondsPerMilliSecond = 1000; regionOfInterest:(CGRect)roi error:(NSError **)error { std::optional rect = - [_visionTaskRunner normalizedRectFromRegionOfInterest:roi - imageSize:CGSizeMake(image.width, image.height) + [_visionTaskRunner normalizedRectWithRegionOfInterest:roi imageOrientation:image.orientation - ROIAllowed:YES + imageSize:CGSizeMake(image.width, image.height) error:error]; if (!rect.has_value()) { return nil; @@ -196,15 +195,18 @@ static const int kMicroSecondsPerMilliSecond = 1000; outputPacketMap.value()[kClassificationsStreamName.cppString]]; } +- (nullable MPPImageClassifierResult *)classifyImage:(MPPImage *)image error:(NSError **)error { + return [self classifyImage:image regionOfInterest:CGRectZero error:error]; +} + - (std::optional)inputPacketMapWithMPPImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds regionOfInterest:(CGRect)roi error:(NSError **)error { std::optional rect = - [_visionTaskRunner normalizedRectFromRegionOfInterest:roi - imageSize:CGSizeMake(image.width, image.height) + [_visionTaskRunner normalizedRectWithRegionOfInterest:roi imageOrientation:image.orientation - ROIAllowed:YES + imageSize:CGSizeMake(image.width, image.height) error:error]; if (!rect.has_value()) { return std::nullopt; @@ -225,10 +227,6 @@ static const int kMicroSecondsPerMilliSecond = 1000; return inputPacketMap; } -- (nullable MPPImageClassifierResult *)classifyImage:(MPPImage *)image error:(NSError **)error { - return [self classifyImage:image regionOfInterest:CGRectZero error:error]; -} - - (nullable MPPImageClassifierResult *)classifyVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds regionOfInterest:(CGRect)roi diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm index 27b196d7f..b7924996d 100644 --- a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm @@ -160,10 +160,8 @@ static NSString *const kTaskName = @"objectDetector"; timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { std::optional rect = - [_visionTaskRunner normalizedRectFromRegionOfInterest:CGRectZero + [_visionTaskRunner normalizedRectWithImageOrientation:image.orientation imageSize:CGSizeMake(image.width, image.height) - imageOrientation:image.orientation - ROIAllowed:NO error:error]; if (!rect.has_value()) { return std::nullopt; @@ -188,10 +186,8 @@ static NSString *const kTaskName = @"objectDetector"; regionOfInterest:(CGRect)roi error:(NSError **)error { std::optional rect = - [_visionTaskRunner normalizedRectFromRegionOfInterest:roi + [_visionTaskRunner normalizedRectWithImageOrientation:image.orientation imageSize:CGSizeMake(image.width, image.height) - imageOrientation:image.orientation - ROIAllowed:NO error:error]; if (!rect.has_value()) { return nil;