Updated iOS hand landmarker Objective C API names
This commit is contained in:
parent
9d42744f8a
commit
435bee71e8
|
@ -208,10 +208,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (MPPHandLandmarkerResult *)detectInImageWithFileInfo:(ResourceFileInfo *)imageFileInfo
|
- (MPPHandLandmarkerResult *)detectImageWithFileInfo:(ResourceFileInfo *)imageFileInfo
|
||||||
usingHandLandmarker:(MPPHandLandmarker *)handLandmarker {
|
usingHandLandmarker:(MPPHandLandmarker *)handLandmarker {
|
||||||
MPPImage *mppImage = [self imageWithFileInfo:imageFileInfo];
|
MPPImage *mppImage = [self imageWithFileInfo:imageFileInfo];
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInImage:mppImage error:nil];
|
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectImage:mppImage error:nil];
|
||||||
XCTAssertNotNil(handLandmarkerResult);
|
XCTAssertNotNil(handLandmarkerResult);
|
||||||
|
|
||||||
return handLandmarkerResult;
|
return handLandmarkerResult;
|
||||||
|
@ -221,8 +221,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
usingHandLandmarker:(MPPHandLandmarker *)handLandmarker
|
usingHandLandmarker:(MPPHandLandmarker *)handLandmarker
|
||||||
approximatelyEqualsHandLandmarkerResult:
|
approximatelyEqualsHandLandmarkerResult:
|
||||||
(MPPHandLandmarkerResult *)expectedHandLandmarkerResult {
|
(MPPHandLandmarkerResult *)expectedHandLandmarkerResult {
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult = [self detectInImageWithFileInfo:fileInfo
|
MPPHandLandmarkerResult *handLandmarkerResult = [self detectImageWithFileInfo:fileInfo
|
||||||
usingHandLandmarker:handLandmarker];
|
usingHandLandmarker:handLandmarker];
|
||||||
[self assertHandLandmarkerResult:handLandmarkerResult
|
[self assertHandLandmarkerResult:handLandmarkerResult
|
||||||
isApproximatelyEqualToExpectedResult:expectedHandLandmarkerResult];
|
isApproximatelyEqualToExpectedResult:expectedHandLandmarkerResult];
|
||||||
}
|
}
|
||||||
|
@ -249,8 +249,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker =
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:handLandmarkerOptions];
|
[self createHandLandmarkerWithOptionsSucceeds:handLandmarkerOptions];
|
||||||
|
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult = [self detectInImageWithFileInfo:kNoHandsImage
|
MPPHandLandmarkerResult *handLandmarkerResult = [self detectImageWithFileInfo:kNoHandsImage
|
||||||
usingHandLandmarker:handLandmarker];
|
usingHandLandmarker:handLandmarker];
|
||||||
AssertHandLandmarkerResultIsEmpty(handLandmarkerResult);
|
AssertHandLandmarkerResultIsEmpty(handLandmarkerResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +264,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker =
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:handLandmarkerOptions];
|
[self createHandLandmarkerWithOptionsSucceeds:handLandmarkerOptions];
|
||||||
|
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult = [self detectInImageWithFileInfo:kTwoHandsImage
|
MPPHandLandmarkerResult *handLandmarkerResult = [self detectImageWithFileInfo:kTwoHandsImage
|
||||||
usingHandLandmarker:handLandmarker];
|
usingHandLandmarker:handLandmarker];
|
||||||
|
|
||||||
XCTAssertTrue(handLandmarkerResult.handedness.count == numHands);
|
XCTAssertTrue(handLandmarkerResult.handedness.count == numHands);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *mppImage = [self imageWithFileInfo:kPointingUpRotatedImage
|
MPPImage *mppImage = [self imageWithFileInfo:kPointingUpRotatedImage
|
||||||
orientation:UIImageOrientationRight];
|
orientation:UIImageOrientationRight];
|
||||||
|
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInImage:mppImage error:nil];
|
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectImage:mppImage error:nil];
|
||||||
|
|
||||||
[self assertHandLandmarkerResult:handLandmarkerResult
|
[self assertHandLandmarkerResult:handLandmarkerResult
|
||||||
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests
|
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests
|
||||||
|
@ -339,9 +339,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
NSError *liveStreamApiCallError;
|
NSError *liveStreamApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
XCTAssertFalse([handLandmarker detectAsyncImage:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&liveStreamApiCallError]);
|
error:&liveStreamApiCallError]);
|
||||||
|
|
||||||
NSError *expectedLiveStreamApiCallError =
|
NSError *expectedLiveStreamApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -354,9 +354,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
|
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
|
||||||
|
|
||||||
NSError *videoApiCallError;
|
NSError *videoApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectInVideoFrame:image
|
XCTAssertFalse([handLandmarker detectVideoFrame:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&videoApiCallError]);
|
error:&videoApiCallError]);
|
||||||
|
|
||||||
NSError *expectedVideoApiCallError =
|
NSError *expectedVideoApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -378,9 +378,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
NSError *liveStreamApiCallError;
|
NSError *liveStreamApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
XCTAssertFalse([handLandmarker detectAsyncImage:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&liveStreamApiCallError]);
|
error:&liveStreamApiCallError]);
|
||||||
|
|
||||||
NSError *expectedLiveStreamApiCallError =
|
NSError *expectedLiveStreamApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -393,7 +393,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
|
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
|
||||||
|
|
||||||
NSError *imageApiCallError;
|
NSError *imageApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectInImage:image error:&imageApiCallError]);
|
XCTAssertFalse([handLandmarker detectImage:image error:&imageApiCallError]);
|
||||||
|
|
||||||
NSError *expectedImageApiCallError =
|
NSError *expectedImageApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -416,7 +416,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
NSError *imageApiCallError;
|
NSError *imageApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectInImage:image error:&imageApiCallError]);
|
XCTAssertFalse([handLandmarker detectImage:image error:&imageApiCallError]);
|
||||||
|
|
||||||
NSError *expectedImageApiCallError =
|
NSError *expectedImageApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -428,9 +428,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
AssertEqualErrors(imageApiCallError, expectedImageApiCallError);
|
AssertEqualErrors(imageApiCallError, expectedImageApiCallError);
|
||||||
|
|
||||||
NSError *videoApiCallError;
|
NSError *videoApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectInVideoFrame:image
|
XCTAssertFalse([handLandmarker detectVideoFrame:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&videoApiCallError]);
|
error:&videoApiCallError]);
|
||||||
|
|
||||||
NSError *expectedVideoApiCallError =
|
NSError *expectedVideoApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -452,9 +452,9 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInVideoFrame:image
|
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectVideoFrame:image
|
||||||
timestampInMilliseconds:i
|
timestampInMilliseconds:i
|
||||||
error:nil];
|
error:nil];
|
||||||
[self assertHandLandmarkerResult:handLandmarkerResult
|
[self assertHandLandmarkerResult:handLandmarkerResult
|
||||||
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests thumbUpHandLandmarkerResult]];
|
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests thumbUpHandLandmarkerResult]];
|
||||||
}
|
}
|
||||||
|
@ -480,10 +480,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
XCTAssertTrue([handLandmarker detectAsyncInImage:image timestampInMilliseconds:1 error:nil]);
|
XCTAssertTrue([handLandmarker detectAsyncImage:image timestampInMilliseconds:1 error:nil]);
|
||||||
|
|
||||||
NSError *error;
|
NSError *error;
|
||||||
XCTAssertFalse([handLandmarker detectAsyncInImage:image timestampInMilliseconds:0 error:&error]);
|
XCTAssertFalse([handLandmarker detectAsyncImage:image timestampInMilliseconds:0 error:&error]);
|
||||||
|
|
||||||
NSError *expectedError =
|
NSError *expectedError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -533,7 +533,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
for (int i = 0; i < iterationCount; i++) {
|
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;
|
NSTimeInterval timeout = 0.5f;
|
||||||
|
|
|
@ -146,7 +146,7 @@ NS_SWIFT_NAME(HandLandmarker)
|
||||||
* @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection
|
* @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
- (nullable MPPHandLandmarkerResult *)detectInImage:(MPPImage *)image
|
- (nullable MPPHandLandmarkerResult *)detectImage:(MPPImage *)image
|
||||||
error:(NSError **)error NS_SWIFT_NAME(detect(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
|
* @return An `HandLandmarkerResult` object that contains the hand hand landmarks detection
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
- (nullable MPPHandLandmarkerResult *)detectInVideoFrame:(MPPImage *)image
|
- (nullable MPPHandLandmarkerResult *)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:));
|
||||||
|
@ -216,7 +216,7 @@ NS_SWIFT_NAME(HandLandmarker)
|
||||||
*
|
*
|
||||||
* @return `YES` if the image was sent to the task successfully, otherwise `NO`.
|
* @return `YES` if the image was sent to the task successfully, otherwise `NO`.
|
||||||
*/
|
*/
|
||||||
- (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:));
|
||||||
|
|
|
@ -140,13 +140,13 @@ static NSString *const kTaskName = @"handLandmarker";
|
||||||
return [self initWithOptions:options error:error];
|
return [self initWithOptions:options error:error];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (nullable MPPHandLandmarkerResult *)detectInImage:(MPPImage *)image error:(NSError **)error {
|
- (nullable MPPHandLandmarkerResult *)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 [MPPHandLandmarker handLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap];
|
return [MPPHandLandmarker handLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (nullable MPPHandLandmarkerResult *)detectInVideoFrame:(MPPImage *)image
|
- (nullable MPPHandLandmarkerResult *)detectVideoFrame:(MPPImage *)image
|
||||||
timestampInMilliseconds:(NSInteger)timestampInMilliseconds
|
timestampInMilliseconds:(NSInteger)timestampInMilliseconds
|
||||||
error:(NSError **)error {
|
error:(NSError **)error {
|
||||||
std::optional<PacketMap> outputPacketMap =
|
std::optional<PacketMap> outputPacketMap =
|
||||||
|
@ -157,7 +157,7 @@ static NSString *const kTaskName = @"handLandmarker";
|
||||||
return [MPPHandLandmarker handLandmarkerResultWithOptionalOutputPacketMap:outputPacketMap];
|
return [MPPHandLandmarker handLandmarkerResultWithOptionalOutputPacketMap: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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user