Updated iOS Face Detector Objective C API names

This commit is contained in:
Prianka Liz Kariat 2023-09-23 00:07:20 +05:30
parent 34cedb980b
commit d7c57e4eda
3 changed files with 32 additions and 32 deletions

View File

@ -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,7 +125,7 @@ static const float kKeypointErrorThreshold = 1e-2;
MPPImage *image = [self imageWithFileInfo:kPortraitImage];
for (int i = 0; i < 3; i++) {
MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectInVideoFrame:image
MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectVideoFrame:image
timestampInMilliseconds:i
error:nil];
[self assertFaceDetectorResult:faceDetectorResult
@ -141,7 +141,7 @@ static const float kKeypointErrorThreshold = 1e-2;
MPPImage *image = [self imageWithFileInfo:kPortraitRotatedImage];
for (int i = 0; i < 3; i++) {
MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectInVideoFrame:image
MPPFaceDetectorResult *faceDetectorResult = [faceDetector detectVideoFrame:image
timestampInMilliseconds:i
error:nil];
[self assertFaceDetectorResult:faceDetectorResult
@ -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,7 +274,7 @@ static const float kKeypointErrorThreshold = 1e-2;
MPPImage *image = [self imageWithFileInfo:kPortraitImage];
NSError *liveStreamApiCallError;
XCTAssertFalse([faceDetector detectAsyncInImage:image
XCTAssertFalse([faceDetector detectAsyncImage:image
timestampInMilliseconds:0
error:&liveStreamApiCallError]);
@ -288,7 +288,7 @@ static const float kKeypointErrorThreshold = 1e-2;
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
NSError *videoApiCallError;
XCTAssertFalse([faceDetector detectInVideoFrame:image
XCTAssertFalse([faceDetector detectVideoFrame:image
timestampInMilliseconds:0
error:&videoApiCallError]);
@ -312,7 +312,7 @@ static const float kKeypointErrorThreshold = 1e-2;
MPPImage *image = [self imageWithFileInfo:kPortraitImage];
NSError *liveStreamApiCallError;
XCTAssertFalse([faceDetector detectAsyncInImage:image
XCTAssertFalse([faceDetector detectAsyncImage:image
timestampInMilliseconds:0
error:&liveStreamApiCallError]);
@ -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,7 +362,7 @@ static const float kKeypointErrorThreshold = 1e-2;
AssertEqualErrors(imageApiCallError, expectedImageApiCallError);
NSError *videoApiCallError;
XCTAssertFalse([faceDetector detectInVideoFrame:image
XCTAssertFalse([faceDetector detectVideoFrame:image
timestampInMilliseconds:0
error:&videoApiCallError]);
@ -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<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];

View File

@ -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:));

View File

@ -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<PacketMap> 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<PacketMap> 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