Updated iOS Object Detector Objective C API names

This commit is contained in:
Prianka Liz Kariat 2023-09-23 00:08:43 +05:30
parent 435bee71e8
commit 2d4e5a75b3
3 changed files with 31 additions and 31 deletions

View File

@ -194,7 +194,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
usingObjectDetector:(MPPObjectDetector *)objectDetector usingObjectDetector:(MPPObjectDetector *)objectDetector
maxResults:(NSInteger)maxResults maxResults:(NSInteger)maxResults
equalsObjectDetectorResult:(MPPObjectDetectorResult *)expectedObjectDetectorResult { equalsObjectDetectorResult:(MPPObjectDetectorResult *)expectedObjectDetectorResult {
MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectInImage:mppImage error:nil]; MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectImage:mppImage error:nil];
[self assertObjectDetectorResult:ObjectDetectorResult [self assertObjectDetectorResult:ObjectDetectorResult
isEqualToExpectedResult:expectedObjectDetectorResult isEqualToExpectedResult:expectedObjectDetectorResult
@ -495,7 +495,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage];
NSError *liveStreamApiCallError; NSError *liveStreamApiCallError;
XCTAssertFalse([objectDetector detectAsyncInImage:image XCTAssertFalse([objectDetector detectAsyncImage:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&liveStreamApiCallError]); error:&liveStreamApiCallError]);
@ -510,7 +510,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
NSError *videoApiCallError; NSError *videoApiCallError;
XCTAssertFalse([objectDetector detectInVideoFrame:image XCTAssertFalse([objectDetector detectVideoFrame:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&videoApiCallError]); error:&videoApiCallError]);
@ -533,7 +533,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage];
NSError *liveStreamApiCallError; NSError *liveStreamApiCallError;
XCTAssertFalse([objectDetector detectAsyncInImage:image XCTAssertFalse([objectDetector detectAsyncImage:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&liveStreamApiCallError]); error:&liveStreamApiCallError]);
@ -548,7 +548,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError); AssertEqualErrors(liveStreamApiCallError, expectedLiveStreamApiCallError);
NSError *imageApiCallError; NSError *imageApiCallError;
XCTAssertFalse([objectDetector detectInImage:image error:&imageApiCallError]); XCTAssertFalse([objectDetector detectImage:image error:&imageApiCallError]);
NSError *expectedImageApiCallError = NSError *expectedImageApiCallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -571,7 +571,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage];
NSError *imageApiCallError; NSError *imageApiCallError;
XCTAssertFalse([objectDetector detectInImage:image error:&imageApiCallError]); XCTAssertFalse([objectDetector detectImage:image error:&imageApiCallError]);
NSError *expectedImageApiCallError = NSError *expectedImageApiCallError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -583,7 +583,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
AssertEqualErrors(imageApiCallError, expectedImageApiCallError); AssertEqualErrors(imageApiCallError, expectedImageApiCallError);
NSError *videoApiCallError; NSError *videoApiCallError;
XCTAssertFalse([objectDetector detectInVideoFrame:image XCTAssertFalse([objectDetector detectVideoFrame:image
timestampInMilliseconds:0 timestampInMilliseconds:0
error:&videoApiCallError]); error:&videoApiCallError]);
@ -610,7 +610,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectInVideoFrame:image MPPObjectDetectorResult *ObjectDetectorResult = [objectDetector detectVideoFrame:image
timestampInMilliseconds:i timestampInMilliseconds:i
error:nil]; error:nil];
@ -643,10 +643,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage];
XCTAssertTrue([objectDetector detectAsyncInImage:image timestampInMilliseconds:1 error:nil]); XCTAssertTrue([objectDetector detectAsyncImage:image timestampInMilliseconds:1 error:nil]);
NSError *error; NSError *error;
XCTAssertFalse([objectDetector detectAsyncInImage:image timestampInMilliseconds:0 error:&error]); XCTAssertFalse([objectDetector detectAsyncImage:image timestampInMilliseconds:0 error:&error]);
NSError *expectedError = NSError *expectedError =
[NSError errorWithDomain:kExpectedErrorDomain [NSError errorWithDomain:kExpectedErrorDomain
@ -702,7 +702,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage]; MPPImage *image = [self imageWithFileInfo:kCatsAndDogsImage];
for (int i = 0; i < iterationCount; i++) { 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; NSTimeInterval timeout = 0.5f;

View File

@ -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 * system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying
* image data. * image data.
*/ */
- (nullable MPPObjectDetectorResult *)detectInImage:(MPPImage *)image - (nullable MPPObjectDetectorResult *)detectImage:(MPPImage *)image
error:(NSError **)error NS_SWIFT_NAME(detect(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 * system, i.e. in `[0,image_width) x [0,image_height)`, which are the dimensions of the underlying
* image data. * image data.
*/ */
- (nullable MPPObjectDetectorResult *)detectInVideoFrame:(MPPImage *)image - (nullable MPPObjectDetectorResult *)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:));
@ -176,7 +176,7 @@ NS_SWIFT_NAME(ObjectDetector)
* *
* @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

@ -128,13 +128,13 @@ static NSString *const kTaskName = @"objectDetector";
return [self initWithOptions:options error:error]; return [self initWithOptions:options error:error];
} }
- (nullable MPPObjectDetectorResult *)detectInImage:(MPPImage *)image error:(NSError **)error { - (nullable MPPObjectDetectorResult *)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 [MPPObjectDetector objectDetectorResultWithOptionalOutputPacketMap:outputPacketMap]; return [MPPObjectDetector objectDetectorResultWithOptionalOutputPacketMap:outputPacketMap];
} }
- (nullable MPPObjectDetectorResult *)detectInVideoFrame:(MPPImage *)image - (nullable MPPObjectDetectorResult *)detectVideoFrame:(MPPImage *)image
timestampInMilliseconds:(NSInteger)timestampInMilliseconds timestampInMilliseconds:(NSInteger)timestampInMilliseconds
error:(NSError **)error { error:(NSError **)error {
std::optional<PacketMap> outputPacketMap = std::optional<PacketMap> outputPacketMap =
@ -145,7 +145,7 @@ static NSString *const kTaskName = @"objectDetector";
return [MPPObjectDetector objectDetectorResultWithOptionalOutputPacketMap:outputPacketMap]; return [MPPObjectDetector objectDetectorResultWithOptionalOutputPacketMap: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