From d7c57e4edaf5c461a22cea7c8020518f4105bac5 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Sat, 23 Sep 2023 00:07:20 +0530 Subject: [PATCH 1/4] Updated iOS Face Detector Objective C API names --- .../face_detector/MPPFaceDetectorTests.mm | 52 +++++++++---------- .../face_detector/sources/MPPFaceDetector.h | 6 +-- .../face_detector/sources/MPPFaceDetector.mm | 6 +-- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/mediapipe/tasks/ios/test/vision/face_detector/MPPFaceDetectorTests.mm b/mediapipe/tasks/ios/test/vision/face_detector/MPPFaceDetectorTests.mm index 548c4bdbf..752f4bfb9 100644 --- a/mediapipe/tasks/ios/test/vision/face_detector/MPPFaceDetectorTests.mm +++ b/mediapipe/tasks/ios/test/vision/face_detector/MPPFaceDetectorTests.mm @@ -109,7 +109,7 @@ static const float kKeypointErrorThreshold = 1e-2; NSError *error; MPPImage *mppImage = [self imageWithFileInfo:kCatImage]; - MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectInImage:mppImage error:&error]; + MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectImage:mppImage error:&error]; XCTAssertNil(error); XCTAssertNotNil(faceDetectorResult); XCTAssertEqual(faceDetectorResult.detections.count, 0); @@ -125,9 +125,9 @@ static const float kKeypointErrorThreshold = 1e-2; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; for (int i = 0; i < 3; i++) { - MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectInVideoFrame:image - timestampInMilliseconds:i - error:nil]; + MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectVideoFrame:image + timestampInMilliseconds:i + error:nil]; [self assertFaceDetectorResult:faceDetectorResult containsExpectedKeypoints:kPortraitExpectedKeypoints]; } @@ -141,9 +141,9 @@ static const float kKeypointErrorThreshold = 1e-2; MPPImage *image = [self imageWithFileInfo:kPortraitRotatedImage]; for (int i = 0; i < 3; i++) { - MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectInVideoFrame:image - timestampInMilliseconds:i - error:nil]; + MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectVideoFrame:image + timestampInMilliseconds:i + error:nil]; [self assertFaceDetectorResult:faceDetectorResult containsExpectedKeypoints:kPortraitRotatedExpectedKeypoints]; } @@ -181,7 +181,7 @@ static const float kKeypointErrorThreshold = 1e-2; }; for (int i = 0; i < iterationCount; i++) { - XCTAssertTrue([faceDetector detectAsyncInImage:image timestampInMilliseconds:i error:nil]); + XCTAssertTrue([faceDetector detectAsyncImage:image timestampInMilliseconds:i error:nil]); } NSTimeInterval timeout = 0.5f; @@ -205,10 +205,10 @@ static const float kKeypointErrorThreshold = 1e-2; }; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; - XCTAssertTrue([faceDetector detectAsyncInImage:image timestampInMilliseconds:1 error:nil]); + XCTAssertTrue([faceDetector detectAsyncImage:image timestampInMilliseconds:1 error:nil]); NSError *error; - XCTAssertFalse([faceDetector detectAsyncInImage:image timestampInMilliseconds:0 error:&error]); + XCTAssertFalse([faceDetector detectAsyncImage:image timestampInMilliseconds:0 error:&error]); NSError *expectedError = [NSError errorWithDomain:kExpectedErrorDomain @@ -274,9 +274,9 @@ static const float kKeypointErrorThreshold = 1e-2; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; NSError *liveStreamApiCallError; - XCTAssertFalse([faceDetector detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamApiCallError]); + XCTAssertFalse([faceDetector detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamApiCallError]); NSError *expectedLiveStreamApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -288,9 +288,9 @@ static const float kKeypointErrorThreshold = 1e-2; AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); NSError *videoApiCallError; - XCTAssertFalse([faceDetector detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoApiCallError]); + XCTAssertFalse([faceDetector detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoApiCallError]); NSError *expectedVideoApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -312,9 +312,9 @@ static const float kKeypointErrorThreshold = 1e-2; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; NSError *liveStreamApiCallError; - XCTAssertFalse([faceDetector detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamApiCallError]); + XCTAssertFalse([faceDetector detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamApiCallError]); NSError *expectedLiveStreamApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -326,7 +326,7 @@ static const float kKeypointErrorThreshold = 1e-2; AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); NSError *imageApiCallError; - XCTAssertFalse([faceDetector detectInImage:image error:&imageApiCallError]); + XCTAssertFalse([faceDetector detectImage:image error:&imageApiCallError]); NSError *expectedImageApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -350,7 +350,7 @@ static const float kKeypointErrorThreshold = 1e-2; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; NSError *imageApiCallError; - XCTAssertFalse([faceDetector detectInImage:image error:&imageApiCallError]); + XCTAssertFalse([faceDetector detectImage:image error:&imageApiCallError]); NSError *expectedImageApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -362,9 +362,9 @@ static const float kKeypointErrorThreshold = 1e-2; AssertEqualErrors(imageApiCallError, expectedImageApiCallError); NSError *videoApiCallError; - XCTAssertFalse([faceDetector detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoApiCallError]); + XCTAssertFalse([faceDetector detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoApiCallError]); NSError *expectedVideoApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -407,7 +407,7 @@ static const float kKeypointErrorThreshold = 1e-2; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; for (int i = 0; i < iterationCount; i++) { - XCTAssertTrue([faceDetector detectAsyncInImage:image timestampInMilliseconds:i error:nil]); + XCTAssertTrue([faceDetector detectAsyncImage:image timestampInMilliseconds:i error:nil]); } NSTimeInterval timeout = 0.5f; @@ -503,7 +503,7 @@ static const float kKeypointErrorThreshold = 1e-2; usingFaceDetector:(MPPFaceDetector *)faceDetector containsExpectedKeypoints:(NSArray *)expectedKeypoints { NSError *error; - MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectInImage:mppImage error:&error]; + MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectImage:mppImage error:&error]; XCTAssertNil(error); XCTAssertNotNil(faceDetectorResult); [self assertFaceDetectorResult:faceDetectorResult containsExpectedKeypoints:expectedKeypoints]; diff --git a/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.h b/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.h index 8adb40679..89cf3d2d3 100644 --- a/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.h +++ b/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.h @@ -100,7 +100,7 @@ NS_SWIFT_NAME(FaceDetector) * system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying * image data. */ -- (nullable MPPFaceDetectorResult *)detectInImage:(MPPImage *)image +- (nullable MPPFaceDetectorResult *)detectImage:(MPPImage *)image error:(NSError **)error NS_SWIFT_NAME(detect(image:)); /** @@ -127,7 +127,7 @@ NS_SWIFT_NAME(FaceDetector) * system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying * image data. */ -- (nullable MPPFaceDetectorResult *)detectInVideoFrame:(MPPImage *)image +- (nullable MPPFaceDetectorResult *)detectVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:)); @@ -165,7 +165,7 @@ NS_SWIFT_NAME(FaceDetector) * * @return `true` if the image was sent to the task successfully, otherwise `false`. */ -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detectAsync(image:timestampInMilliseconds:)); diff --git a/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.mm b/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.mm index 8e82281b4..96434eb47 100644 --- a/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.mm +++ b/mediapipe/tasks/ios/vision/face_detector/sources/MPPFaceDetector.mm @@ -130,13 +130,13 @@ static NSString *const kTaskName = @"faceDetector"; return [self initWithOptions:options error:error]; } -- (nullable MPPFaceDetectorResult *)detectInImage:(MPPImage *)image error:(NSError **)error { +- (nullable MPPFaceDetectorResult *)detectImage:(MPPImage *)image error:(NSError **)error { std::optional outputPacketMap = [_visionTaskRunner processImage:image error:error]; return [MPPFaceDetector faceDetectorResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (nullable MPPFaceDetectorResult *)detectInVideoFrame:(MPPImage *)image +- (nullable MPPFaceDetectorResult *)detectVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { std::optional outputPacketMap = @@ -147,7 +147,7 @@ static NSString *const kTaskName = @"faceDetector"; return [MPPFaceDetector faceDetectorResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { return [_visionTaskRunner processLiveStreamImage:image From 9d42744f8ab0996651d9894062a7308997849f1a Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Sat, 23 Sep 2023 00:07:49 +0530 Subject: [PATCH 2/4] Updated iOS Face Landmarker Objective C API names --- .../face_landmarker/MPPFaceLandmarkerTests.mm | 48 +++++++++---------- .../sources/MPPFaceLandmarker.h | 12 ++--- .../sources/MPPFaceLandmarker.mm | 10 ++-- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/mediapipe/tasks/ios/test/vision/face_landmarker/MPPFaceLandmarkerTests.mm b/mediapipe/tasks/ios/test/vision/face_landmarker/MPPFaceLandmarkerTests.mm index 3ebc89466..9e92b76c9 100644 --- a/mediapipe/tasks/ios/test/vision/face_landmarker/MPPFaceLandmarkerTests.mm +++ b/mediapipe/tasks/ios/test/vision/face_landmarker/MPPFaceLandmarkerTests.mm @@ -137,8 +137,8 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; NSError *error; MPPImage *mppImage = [self imageWithFileInfo:kCatImage]; - MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectInImage:mppImage - error:&error]; + MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectImage:mppImage + error:&error]; XCTAssertNil(error); XCTAssertNotNil(faceLandmarkerResult); XCTAssertEqualObjects(faceLandmarkerResult.faceLandmarks, [NSArray array]); @@ -158,9 +158,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; NSArray *expectedLandmarks = [MPPFaceLandmarkerTests expectedLandmarksFromFileInfo:kPortraitExpectedLandmarksName]; for (int i = 0; i < 3; i++) { - MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectInVideoFrame:image - timestampInMilliseconds:i - error:nil]; + MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectVideoFrame:image + timestampInMilliseconds:i + error:nil]; [self assertFaceLandmarkerResult:faceLandmarkerResult containsExpectedLandmarks:expectedLandmarks expectedBlendshapes:NULL @@ -200,7 +200,7 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; }; for (int i = 0; i < iterationCount; i++) { - XCTAssertTrue([faceLandmarker detectAsyncInImage:image timestampInMilliseconds:i error:nil]); + XCTAssertTrue([faceLandmarker detectAsyncImage:image timestampInMilliseconds:i error:nil]); } NSTimeInterval timeout = 0.5f; @@ -224,10 +224,10 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; }; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; - XCTAssertTrue([faceLandmarker detectAsyncInImage:image timestampInMilliseconds:1 error:nil]); + XCTAssertTrue([faceLandmarker detectAsyncImage:image timestampInMilliseconds:1 error:nil]); NSError *error; - XCTAssertFalse([faceLandmarker detectAsyncInImage:image timestampInMilliseconds:0 error:&error]); + XCTAssertFalse([faceLandmarker detectAsyncImage:image timestampInMilliseconds:0 error:&error]); NSError *expectedError = [NSError errorWithDomain:kExpectedErrorDomain @@ -292,9 +292,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; NSError *liveStreamAPICallError; - XCTAssertFalse([faceLandmarker detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamAPICallError]); + XCTAssertFalse([faceLandmarker detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamAPICallError]); NSError *expectedLiveStreamAPICallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -306,9 +306,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; AssertEqualErrors(liveStreamAPICallError, expectedLiveStreamAPICallError); NSError *videoAPICallError; - XCTAssertFalse([faceLandmarker detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoAPICallError]); + XCTAssertFalse([faceLandmarker detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoAPICallError]); NSError *expectedVideoAPICallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -329,9 +329,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; NSError *liveStreamAPICallError; - XCTAssertFalse([faceLandmarker detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamAPICallError]); + XCTAssertFalse([faceLandmarker detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamAPICallError]); NSError *expectedLiveStreamAPICallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -343,7 +343,7 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; AssertEqualErrors(liveStreamAPICallError, expectedLiveStreamAPICallError); NSError *imageAPICallError; - XCTAssertFalse([faceLandmarker detectInImage:image error:&imageAPICallError]); + XCTAssertFalse([faceLandmarker detectImage:image error:&imageAPICallError]); NSError *expectedImageAPICallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -365,7 +365,7 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; MPPImage *image = [self imageWithFileInfo:kPortraitImage]; NSError *imageAPICallError; - XCTAssertFalse([faceLandmarker detectInImage:image error:&imageAPICallError]); + XCTAssertFalse([faceLandmarker detectImage:image error:&imageAPICallError]); NSError *expectedImageAPICallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -377,9 +377,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; AssertEqualErrors(imageAPICallError, expectedImageAPICallError); NSError *videoAPICallError; - XCTAssertFalse([faceLandmarker detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoAPICallError]); + XCTAssertFalse([faceLandmarker detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoAPICallError]); NSError *expectedVideoAPICallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -539,8 +539,8 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f; MPPImage *mppImage = [self imageWithFileInfo:fileInfo]; NSError *error; - MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectInImage:mppImage - error:&error]; + MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectImage:mppImage + error:&error]; XCTAssertNil(error); XCTAssertNotNil(faceLandmarkerResult); diff --git a/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.h b/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.h index ce4e991dd..53cb8ecd7 100644 --- a/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.h +++ b/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.h @@ -71,8 +71,8 @@ NS_SWIFT_NAME(FaceLandmarker) * @return An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an error * in initializing the face landmaker. */ -- (nullable MPPFaceLandmarkerResult *)detectInImage:(MPPImage *)image - error:(NSError **)error NS_SWIFT_NAME(detect(image:)); +- (nullable MPPFaceLandmarkerResult *)detectImage:(MPPImage *)image + error:(NSError **)error NS_SWIFT_NAME(detect(image:)); /** * Performs face landmark detection on the provided video frame of type `MPImage` using the whole @@ -95,9 +95,9 @@ NS_SWIFT_NAME(FaceLandmarker) * @return An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an * error in initializing the face landmaker. */ -- (nullable MPPFaceLandmarkerResult *)detectInVideoFrame:(MPPImage *)image - timestampInMilliseconds:(NSInteger)timestampInMilliseconds - error:(NSError **)error +- (nullable MPPFaceLandmarkerResult *)detectVideoFrame:(MPPImage *)image + timestampInMilliseconds:(NSInteger)timestampInMilliseconds + error:(NSError **)error NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:)); /** @@ -132,7 +132,7 @@ NS_SWIFT_NAME(FaceLandmarker) * * @return `true` if the image was sent to the task successfully, otherwise `false`. */ -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detectAsync(image:timestampInMilliseconds:)); diff --git a/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.mm b/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.mm index 820ab44ae..8a128475d 100644 --- a/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.mm +++ b/mediapipe/tasks/ios/vision/face_landmarker/sources/MPPFaceLandmarker.mm @@ -154,15 +154,15 @@ static NSString *const kTaskName = @"faceLandmarker"; return [self initWithOptions:options error:error]; } -- (nullable MPPFaceLandmarkerResult *)detectInImage:(MPPImage *)image error:(NSError **)error { +- (nullable MPPFaceLandmarkerResult *)detectImage:(MPPImage *)image error:(NSError **)error { std::optional outputPacketMap = [_visionTaskRunner processImage:image error:error]; return [MPPFaceLandmarker faceLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (nullable MPPFaceLandmarkerResult *)detectInVideoFrame:(MPPImage *)image - timestampInMilliseconds:(NSInteger)timestampInMilliseconds - error:(NSError **)error { +- (nullable MPPFaceLandmarkerResult *)detectVideoFrame:(MPPImage *)image + timestampInMilliseconds:(NSInteger)timestampInMilliseconds + error:(NSError **)error { std::optional outputPacketMap = [_visionTaskRunner processVideoFrame:image timestampInMilliseconds:timestampInMilliseconds @@ -171,7 +171,7 @@ static NSString *const kTaskName = @"faceLandmarker"; return [MPPFaceLandmarker faceLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { return [_visionTaskRunner processLiveStreamImage:image From 435bee71e8bbdef994c10e81f115d7cbdf7f61d3 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Sat, 23 Sep 2023 00:08:07 +0530 Subject: [PATCH 3/4] Updated iOS hand landmarker Objective C API names --- .../hand_landmarker/MPPHandLandmarkerTests.m | 60 +++++++++---------- .../sources/MPPHandLandmarker.h | 6 +- .../sources/MPPHandLandmarker.mm | 6 +- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/mediapipe/tasks/ios/test/vision/hand_landmarker/MPPHandLandmarkerTests.m b/mediapipe/tasks/ios/test/vision/hand_landmarker/MPPHandLandmarkerTests.m index 1e7470d8e..9e27937d8 100644 --- a/mediapipe/tasks/ios/test/vision/hand_landmarker/MPPHandLandmarkerTests.m +++ b/mediapipe/tasks/ios/test/vision/hand_landmarker/MPPHandLandmarkerTests.m @@ -208,10 +208,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; return image; } -- (MPPHandLandmarkerResult *)detectInImageWithFileInfo:(ResourceFileInfo *)imageFileInfo - usingHandLandmarker:(MPPHandLandmarker *)handLandmarker { +- (MPPHandLandmarkerResult *)detectImageWithFileInfo:(ResourceFileInfo *)imageFileInfo + usingHandLandmarker:(MPPHandLandmarker *)handLandmarker { MPPImage *mppImage = [self imageWithFileInfo:imageFileInfo]; - MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInImage:mppImage error:nil]; + MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectImage:mppImage error:nil]; XCTAssertNotNil(handLandmarkerResult); return handLandmarkerResult; @@ -221,8 +221,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; usingHandLandmarker:(MPPHandLandmarker *)handLandmarker approximatelyEqualsHandLandmarkerResult: (MPPHandLandmarkerResult *)expectedHandLandmarkerResult { - MPPHandLandmarkerResult *handLandmarkerResult = [self detectInImageWithFileInfo:fileInfo - usingHandLandmarker:handLandmarker]; + MPPHandLandmarkerResult *handLandmarkerResult = [self detectImageWithFileInfo:fileInfo + usingHandLandmarker:handLandmarker]; [self assertHandLandmarkerResult:handLandmarkerResult isApproximatelyEqualToExpectedResult:expectedHandLandmarkerResult]; } @@ -249,8 +249,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:handLandmarkerOptions]; - MPPHandLandmarkerResult *handLandmarkerResult = [self detectInImageWithFileInfo:kNoHandsImage - usingHandLandmarker:handLandmarker]; + MPPHandLandmarkerResult *handLandmarkerResult = [self detectImageWithFileInfo:kNoHandsImage + usingHandLandmarker:handLandmarker]; AssertHandLandmarkerResultIsEmpty(handLandmarkerResult); } @@ -264,8 +264,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:handLandmarkerOptions]; - MPPHandLandmarkerResult *handLandmarkerResult = [self detectInImageWithFileInfo:kTwoHandsImage - usingHandLandmarker:handLandmarker]; + MPPHandLandmarkerResult *handLandmarkerResult = [self detectImageWithFileInfo:kTwoHandsImage + usingHandLandmarker:handLandmarker]; XCTAssertTrue(handLandmarkerResult.handedness.count == numHands); } @@ -280,7 +280,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *mppImage = [self imageWithFileInfo:kPointingUpRotatedImage orientation:UIImageOrientationRight]; - MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInImage:mppImage error:nil]; + MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectImage:mppImage error:nil]; [self assertHandLandmarkerResult:handLandmarkerResult isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests @@ -339,9 +339,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kThumbUpImage]; NSError *liveStreamApiCallError; - XCTAssertFalse([handLandmarker detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamApiCallError]); + XCTAssertFalse([handLandmarker detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamApiCallError]); NSError *expectedLiveStreamApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -354,9 +354,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); NSError *videoApiCallError; - XCTAssertFalse([handLandmarker detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoApiCallError]); + XCTAssertFalse([handLandmarker detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoApiCallError]); NSError *expectedVideoApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -378,9 +378,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kThumbUpImage]; NSError *liveStreamApiCallError; - XCTAssertFalse([handLandmarker detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamApiCallError]); + XCTAssertFalse([handLandmarker detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamApiCallError]); NSError *expectedLiveStreamApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -393,7 +393,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); NSError *imageApiCallError; - XCTAssertFalse([handLandmarker detectInImage:image error:&imageApiCallError]); + XCTAssertFalse([handLandmarker detectImage:image error:&imageApiCallError]); NSError *expectedImageApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -416,7 +416,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kThumbUpImage]; NSError *imageApiCallError; - XCTAssertFalse([handLandmarker detectInImage:image error:&imageApiCallError]); + XCTAssertFalse([handLandmarker detectImage:image error:&imageApiCallError]); NSError *expectedImageApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -428,9 +428,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; AssertEqualErrors(imageApiCallError, expectedImageApiCallError); NSError *videoApiCallError; - XCTAssertFalse([handLandmarker detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoApiCallError]); + XCTAssertFalse([handLandmarker detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoApiCallError]); NSError *expectedVideoApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -452,9 +452,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kThumbUpImage]; for (int i = 0; i < 3; i++) { - MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInVideoFrame:image - timestampInMilliseconds:i - error:nil]; + MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectVideoFrame:image + timestampInMilliseconds:i + error:nil]; [self assertHandLandmarkerResult:handLandmarkerResult isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests thumbUpHandLandmarkerResult]]; } @@ -480,10 +480,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kThumbUpImage]; - XCTAssertTrue([handLandmarker detectAsyncInImage:image timestampInMilliseconds:1 error:nil]); + XCTAssertTrue([handLandmarker detectAsyncImage:image timestampInMilliseconds:1 error:nil]); NSError *error; - XCTAssertFalse([handLandmarker detectAsyncInImage:image timestampInMilliseconds:0 error:&error]); + XCTAssertFalse([handLandmarker detectAsyncImage:image timestampInMilliseconds:0 error:&error]); NSError *expectedError = [NSError errorWithDomain:kExpectedErrorDomain @@ -533,7 +533,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kThumbUpImage]; for (int i = 0; i < iterationCount; i++) { - XCTAssertTrue([handLandmarker detectAsyncInImage:image timestampInMilliseconds:i error:nil]); + XCTAssertTrue([handLandmarker detectAsyncImage:image timestampInMilliseconds:i error:nil]); } NSTimeInterval timeout = 0.5f; diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.h b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.h index 80973d391..645f33cd1 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.h +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.h @@ -146,7 +146,7 @@ NS_SWIFT_NAME(HandLandmarker) * @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection * results. */ -- (nullable MPPHandLandmarkerResult *)detectInImage:(MPPImage *)image +- (nullable MPPHandLandmarkerResult *)detectImage:(MPPImage *)image error:(NSError **)error NS_SWIFT_NAME(detect(image:)); /** @@ -176,7 +176,7 @@ NS_SWIFT_NAME(HandLandmarker) * @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection * results. */ -- (nullable MPPHandLandmarkerResult *)detectInVideoFrame:(MPPImage *)image +- (nullable MPPHandLandmarkerResult *)detectVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:)); @@ -216,7 +216,7 @@ NS_SWIFT_NAME(HandLandmarker) * * @return `YES` if the image was sent to the task successfully, otherwise `NO`. */ -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detectAsync(image:timestampInMilliseconds:)); diff --git a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.mm b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.mm index cedbf0f23..950cfae91 100644 --- a/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.mm +++ b/mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarker.mm @@ -140,13 +140,13 @@ static NSString *const kTaskName = @"handLandmarker"; return [self initWithOptions:options error:error]; } -- (nullable MPPHandLandmarkerResult *)detectInImage:(MPPImage *)image error:(NSError **)error { +- (nullable MPPHandLandmarkerResult *)detectImage:(MPPImage *)image error:(NSError **)error { std::optional outputPacketMap = [_visionTaskRunner processImage:image error:error]; return [MPPHandLandmarker handLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (nullable MPPHandLandmarkerResult *)detectInVideoFrame:(MPPImage *)image +- (nullable MPPHandLandmarkerResult *)detectVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { std::optional outputPacketMap = @@ -157,7 +157,7 @@ static NSString *const kTaskName = @"handLandmarker"; return [MPPHandLandmarker handLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { return [_visionTaskRunner processLiveStreamImage:image From 2d4e5a75b37c4d12321e36f970b2f26984e6f887 Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Sat, 23 Sep 2023 00:08:43 +0530 Subject: [PATCH 4/4] Updated iOS Object Detector Objective C API names --- .../object_detector/MPPObjectDetectorTests.m | 50 +++++++++---------- .../sources/MPPObjectDetector.h | 6 +-- .../sources/MPPObjectDetector.mm | 6 +-- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/mediapipe/tasks/ios/test/vision/object_detector/MPPObjectDetectorTests.m b/mediapipe/tasks/ios/test/vision/object_detector/MPPObjectDetectorTests.m index 079682df1..7e483c25c 100644 --- a/mediapipe/tasks/ios/test/vision/object_detector/MPPObjectDetectorTests.m +++ b/mediapipe/tasks/ios/test/vision/object_detector/MPPObjectDetectorTests.m @@ -28,10 +28,10 @@ static const float scoreDifferenceTolerance = 0.02f; static NSString *const kLiveStreamTestsDictObjectDetectorKey = @"object_detector"; static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; -#define AssertEqualErrors(error, expectedError) \ - XCTAssertNotNil(error); \ - XCTAssertEqualObjects(error.domain, expectedError.domain); \ - XCTAssertEqual(error.code, expectedError.code); \ +#define AssertEqualErrors(error, expectedError) \ + XCTAssertNotNil(error); \ + XCTAssertEqualObjects(error.domain, expectedError.domain); \ + XCTAssertEqual(error.code, expectedError.code); \ XCTAssertEqualObjects(error.localizedDescription, expectedError.localizedDescription) #define AssertEqualCategories(category, expectedCategory, detectionIndex, categoryIndex) \ @@ -194,7 +194,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; usingObjectDetector:(MPPObjectDetector *)objectDetector maxResults:(NSInteger)maxResults equalsObjectDetectorResult:(MPPObjectDetectorResult *)expectedObjectDetectorResult { - MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectInImage:mppImage error:nil]; + MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectImage:mppImage error:nil]; [self assertObjectDetectorResult:ObjectDetectorResult isEqualToExpectedResult:expectedObjectDetectorResult @@ -495,9 +495,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; NSError *liveStreamApiCallError; - XCTAssertFalse([objectDetector detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamApiCallError]); + XCTAssertFalse([objectDetector detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamApiCallError]); NSError *expectedLiveStreamApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -510,9 +510,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); NSError *videoApiCallError; - XCTAssertFalse([objectDetector detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoApiCallError]); + XCTAssertFalse([objectDetector detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoApiCallError]); NSError *expectedVideoApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -533,9 +533,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; NSError *liveStreamApiCallError; - XCTAssertFalse([objectDetector detectAsyncInImage:image - timestampInMilliseconds:0 - error:&liveStreamApiCallError]); + XCTAssertFalse([objectDetector detectAsyncImage:image + timestampInMilliseconds:0 + error:&liveStreamApiCallError]); NSError *expectedLiveStreamApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -548,7 +548,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); NSError *imageApiCallError; - XCTAssertFalse([objectDetector detectInImage:image error:&imageApiCallError]); + XCTAssertFalse([objectDetector detectImage:image error:&imageApiCallError]); NSError *expectedImageApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -571,7 +571,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; NSError *imageApiCallError; - XCTAssertFalse([objectDetector detectInImage:image error:&imageApiCallError]); + XCTAssertFalse([objectDetector detectImage:image error:&imageApiCallError]); NSError *expectedImageApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -583,9 +583,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; AssertEqualErrors(imageApiCallError, expectedImageApiCallError); NSError *videoApiCallError; - XCTAssertFalse([objectDetector detectInVideoFrame:image - timestampInMilliseconds:0 - error:&videoApiCallError]); + XCTAssertFalse([objectDetector detectVideoFrame:image + timestampInMilliseconds:0 + error:&videoApiCallError]); NSError *expectedVideoApiCallError = [NSError errorWithDomain:kExpectedErrorDomain @@ -610,9 +610,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; for (int i = 0; i < 3; i++) { - MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectInVideoFrame:image - timestampInMilliseconds:i - error:nil]; + MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectVideoFrame:image + timestampInMilliseconds:i + error:nil]; [self assertObjectDetectorResult:ObjectDetectorResult isEqualToExpectedResult: @@ -643,10 +643,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; - XCTAssertTrue([objectDetector detectAsyncInImage:image timestampInMilliseconds:1 error:nil]); + XCTAssertTrue([objectDetector detectAsyncImage:image timestampInMilliseconds:1 error:nil]); NSError *error; - XCTAssertFalse([objectDetector detectAsyncInImage:image timestampInMilliseconds:0 error:&error]); + XCTAssertFalse([objectDetector detectAsyncImage:image timestampInMilliseconds:0 error:&error]); NSError *expectedError = [NSError errorWithDomain:kExpectedErrorDomain @@ -702,7 +702,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation"; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; for (int i = 0; i < iterationCount; i++) { - XCTAssertTrue([objectDetector detectAsyncInImage:image timestampInMilliseconds:i error:nil]); + XCTAssertTrue([objectDetector detectAsyncImage:image timestampInMilliseconds:i error:nil]); } NSTimeInterval timeout = 0.5f; diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.h b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.h index 82721f47b..4b10fb558 100644 --- a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.h +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.h @@ -112,7 +112,7 @@ NS_SWIFT_NAME(ObjectDetector) * system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying * image data. */ -- (nullable MPPObjectDetectorResult *)detectInImage:(MPPImage *)image +- (nullable MPPObjectDetectorResult *)detectImage:(MPPImage *)image error:(NSError **)error NS_SWIFT_NAME(detect(image:)); /** @@ -138,7 +138,7 @@ NS_SWIFT_NAME(ObjectDetector) * system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying * image data. */ -- (nullable MPPObjectDetectorResult *)detectInVideoFrame:(MPPImage *)image +- (nullable MPPObjectDetectorResult *)detectVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:)); @@ -176,7 +176,7 @@ NS_SWIFT_NAME(ObjectDetector) * * @return `true` if the image was sent to the task successfully, otherwise `false`. */ -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error NS_SWIFT_NAME(detectAsync(image:timestampInMilliseconds:)); diff --git a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm index 86063a1f0..7d2276b2a 100644 --- a/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm +++ b/mediapipe/tasks/ios/vision/object_detector/sources/MPPObjectDetector.mm @@ -128,13 +128,13 @@ static NSString *const kTaskName = @"objectDetector"; return [self initWithOptions:options error:error]; } -- (nullable MPPObjectDetectorResult *)detectInImage:(MPPImage *)image error:(NSError **)error { +- (nullable MPPObjectDetectorResult *)detectImage:(MPPImage *)image error:(NSError **)error { std::optional outputPacketMap = [_visionTaskRunner processImage:image error:error]; return [MPPObjectDetector objectDetectorResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (nullable MPPObjectDetectorResult *)detectInVideoFrame:(MPPImage *)image +- (nullable MPPObjectDetectorResult *)detectVideoFrame:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { std::optional outputPacketMap = @@ -145,7 +145,7 @@ static NSString *const kTaskName = @"objectDetector"; return [MPPObjectDetector objectDetectorResultWithOptionalOutputPacketMap:outputPacketMap]; } -- (BOOL)detectAsyncInImage:(MPPImage *)image +- (BOOL)detectAsyncImage:(MPPImage *)image timestampInMilliseconds:(NSInteger)timestampInMilliseconds error:(NSError **)error { return [_visionTaskRunner processLiveStreamImage:image