Updated iOS Face Landmarker Objective C API names

This commit is contained in:
Prianka Liz Kariat 2023-09-23 00:07:49 +05:30
parent d7c57e4eda
commit 9d42744f8a
3 changed files with 35 additions and 35 deletions

View File

@ -137,8 +137,8 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
NSError *error; NSError *error;
MPPImage *mppImage = [self imageWithFileInfo:kCatImage]; MPPImage *mppImage = [self imageWithFileInfo:kCatImage];
MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectInImage:mppImage MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectImage:mppImage
error:&error]; error:&error];
XCTAssertNil(error); XCTAssertNil(error);
XCTAssertNotNil(faceLandmarkerResult); XCTAssertNotNil(faceLandmarkerResult);
XCTAssertEqualObjects(faceLandmarkerResult.faceLandmarks, [NSArray array]); XCTAssertEqualObjects(faceLandmarkerResult.faceLandmarks, [NSArray array]);
@ -158,9 +158,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
NSArray<MPPNormalizedLandmark *> *expectedLandmarks = NSArray<MPPNormalizedLandmark *> *expectedLandmarks =
[MPPFaceLandmarkerTests expectedLandmarksFromFileInfo:kPortraitExpectedLandmarksName]; [MPPFaceLandmarkerTests expectedLandmarksFromFileInfo:kPortraitExpectedLandmarksName];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectInVideoFrame:image MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectVideoFrame:image
timestampInMilliseconds:i timestampInMilliseconds:i
error:nil]; error:nil];
[self assertFaceLandmarkerResult:faceLandmarkerResult [self assertFaceLandmarkerResult:faceLandmarkerResult
containsExpectedLandmarks:expectedLandmarks containsExpectedLandmarks:expectedLandmarks
expectedBlendshapes:NULL expectedBlendshapes:NULL
@ -200,7 +200,7 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
}; };
for (int i = 0; i < iterationCount; i++) { 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; NSTimeInterval timeout = 0.5f;
@ -224,10 +224,10 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
}; };
MPPImage *image = [self imageWithFileInfo:kPortraitImage]; MPPImage *image = [self imageWithFileInfo:kPortraitImage];
XCTAssertTrue([faceLandmarker detectAsyncInImage:image timestampInMilliseconds:1 error:nil]); XCTAssertTrue([faceLandmarker detectAsyncImage:image timestampInMilliseconds:1 error:nil]);
NSError *error; NSError *error;
XCTAssertFalse([faceLandmarker detectAsyncInImage:image timestampInMilliseconds:0 error:&error]); XCTAssertFalse([faceLandmarker detectAsyncImage:image timestampInMilliseconds:0 error:&error]);
NSError *expectedError = NSError *expectedError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -292,9 +292,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
MPPImage *image = [self imageWithFileInfo:kPortraitImage]; MPPImage *image = [self imageWithFileInfo:kPortraitImage];
NSError *liveStreamAPICallError; NSError *liveStreamAPICallError;
XCTAssertFalse([faceLandmarker detectAsyncInImage:image XCTAssertFalse([faceLandmarker detectAsyncImage:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&liveStreamAPICallError]); error:&liveStreamAPICallError]);
NSError *expectedLiveStreamAPICallError = NSError *expectedLiveStreamAPICallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -306,9 +306,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
AssertEqualErrors(liveStreamAPICallError, expectedLiveStreamAPICallError); AssertEqualErrors(liveStreamAPICallError, expectedLiveStreamAPICallError);
NSError *videoAPICallError; NSError *videoAPICallError;
XCTAssertFalse([faceLandmarker detectInVideoFrame:image XCTAssertFalse([faceLandmarker detectVideoFrame:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&videoAPICallError]); error:&videoAPICallError]);
NSError *expectedVideoAPICallError = NSError *expectedVideoAPICallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -329,9 +329,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
MPPImage *image = [self imageWithFileInfo:kPortraitImage]; MPPImage *image = [self imageWithFileInfo:kPortraitImage];
NSError *liveStreamAPICallError; NSError *liveStreamAPICallError;
XCTAssertFalse([faceLandmarker detectAsyncInImage:image XCTAssertFalse([faceLandmarker detectAsyncImage:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&liveStreamAPICallError]); error:&liveStreamAPICallError]);
NSError *expectedLiveStreamAPICallError = NSError *expectedLiveStreamAPICallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -343,7 +343,7 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
AssertEqualErrors(liveStreamAPICallError, expectedLiveStreamAPICallError); AssertEqualErrors(liveStreamAPICallError, expectedLiveStreamAPICallError);
NSError *imageAPICallError; NSError *imageAPICallError;
XCTAssertFalse([faceLandmarker detectInImage:image error:&imageAPICallError]); XCTAssertFalse([faceLandmarker detectImage:image error:&imageAPICallError]);
NSError *expectedImageAPICallError = NSError *expectedImageAPICallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -365,7 +365,7 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
MPPImage *image = [self imageWithFileInfo:kPortraitImage]; MPPImage *image = [self imageWithFileInfo:kPortraitImage];
NSError *imageAPICallError; NSError *imageAPICallError;
XCTAssertFalse([faceLandmarker detectInImage:image error:&imageAPICallError]); XCTAssertFalse([faceLandmarker detectImage:image error:&imageAPICallError]);
NSError *expectedImageAPICallError = NSError *expectedImageAPICallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -377,9 +377,9 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
AssertEqualErrors(imageAPICallError, expectedImageAPICallError); AssertEqualErrors(imageAPICallError, expectedImageAPICallError);
NSError *videoAPICallError; NSError *videoAPICallError;
XCTAssertFalse([faceLandmarker detectInVideoFrame:image XCTAssertFalse([faceLandmarker detectVideoFrame:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&videoAPICallError]); error:&videoAPICallError]);
NSError *expectedVideoAPICallError = NSError *expectedVideoAPICallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -539,8 +539,8 @@ constexpr float kFacialTransformationMatrixErrorThreshold = 0.2f;
MPPImage *mppImage = [self imageWithFileInfo:fileInfo]; MPPImage *mppImage = [self imageWithFileInfo:fileInfo];
NSError *error; NSError *error;
MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectInImage:mppImage MPPFaceLandmarkerResult *faceLandmarkerResult = [faceLandmarker detectImage:mppImage
error:&error]; error:&error];
XCTAssertNil(error); XCTAssertNil(error);
XCTAssertNotNil(faceLandmarkerResult); XCTAssertNotNil(faceLandmarkerResult);

View File

@ -71,8 +71,8 @@ NS_SWIFT_NAME(FaceLandmarker)
* @return An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an error * @return An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an error
* in initializing the face landmaker. * in initializing the face landmaker.
*/ */
- (nullable MPPFaceLandmarkerResult *)detectInImage:(MPPImage *)image - (nullable MPPFaceLandmarkerResult *)detectImage:(MPPImage *)image
error:(NSError **)error NS_SWIFT_NAME(detect(image:)); error:(NSError **)error NS_SWIFT_NAME(detect(image:));
/** /**
* Performs face landmark detection on the provided video frame of type `MPImage` using the whole * 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 * @return An `FaceLandmarkerResult` that contains a list of landmarks. `nil` if there is an
* error in initializing the face landmaker. * error in initializing the face landmaker.
*/ */
- (nullable MPPFaceLandmarkerResult *)detectInVideoFrame:(MPPImage *)image - (nullable MPPFaceLandmarkerResult *)detectVideoFrame:(MPPImage *)image
timestampInMilliseconds:(NSInteger)timestampInMilliseconds timestampInMilliseconds:(NSInteger)timestampInMilliseconds
error:(NSError **)error error:(NSError **)error
NS_SWIFT_NAME(detect(videoFrame:timestampInMilliseconds:)); 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`. * @return `true` if the image was sent to the task successfully, otherwise `false`.
*/ */
- (BOOL)detectAsyncInImage:(MPPImage *)image - (BOOL)detectAsyncImage:(MPPImage *)image
timestampInMilliseconds:(NSInteger)timestampInMilliseconds timestampInMilliseconds:(NSInteger)timestampInMilliseconds
error:(NSError **)error error:(NSError **)error
NS_SWIFT_NAME(detectAsync(image:timestampInMilliseconds:)); NS_SWIFT_NAME(detectAsync(image:timestampInMilliseconds:));

View File

@ -154,15 +154,15 @@ static NSString *const kTaskName = @"faceLandmarker";
return [self initWithOptions:options error:error]; return [self initWithOptions:options error:error];
} }
- (nullable MPPFaceLandmarkerResult *)detectInImage:(MPPImage *)image error:(NSError **)error { - (nullable MPPFaceLandmarkerResult *)detectImage:(MPPImage *)image error:(NSError **)error {
std::optional<PacketMap> outputPacketMap = [_visionTaskRunner processImage:image error:error]; std::optional<PacketMap> outputPacketMap = [_visionTaskRunner processImage:image error:error];
return [MPPFaceLandmarker faceLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap]; return [MPPFaceLandmarker faceLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap];
} }
- (nullable MPPFaceLandmarkerResult *)detectInVideoFrame:(MPPImage *)image - (nullable MPPFaceLandmarkerResult *)detectVideoFrame:(MPPImage *)image
timestampInMilliseconds:(NSInteger)timestampInMilliseconds timestampInMilliseconds:(NSInteger)timestampInMilliseconds
error:(NSError **)error { error:(NSError **)error {
std::optional<PacketMap> outputPacketMap = std::optional<PacketMap> outputPacketMap =
[_visionTaskRunner processVideoFrame:image [_visionTaskRunner processVideoFrame:image
timestampInMilliseconds:timestampInMilliseconds timestampInMilliseconds:timestampInMilliseconds
@ -171,7 +171,7 @@ static NSString *const kTaskName = @"faceLandmarker";
return [MPPFaceLandmarker faceLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap]; return [MPPFaceLandmarker faceLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap];
} }
- (BOOL)detectAsyncInImage:(MPPImage *)image - (BOOL)detectAsyncImage:(MPPImage *)image
timestampInMilliseconds:(NSInteger)timestampInMilliseconds timestampInMilliseconds:(NSInteger)timestampInMilliseconds
error:(NSError **)error { error:(NSError **)error {
return [_visionTaskRunner processLiveStreamImage:image return [_visionTaskRunner processLiveStreamImage:image