-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for iOS Image Segmenter methods with completion handlers #4830
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,6 +468,45 @@ - (void)imageSegmenter:(MPPImageSegmenter *)imageSegmenter | |
} | ||
} | ||
|
||
#pragma mark Mask No Copy Tests | ||
|
||
- (void)testSegmentWithNoCopyConfidenceMasksAndImageModeSucceeds { | ||
MPPImageSegmenterOptions *options = | ||
[self imageSegmenterOptionsWithModelFileInfo:kImageSegmenterModelFileInfo]; | ||
|
||
MPPImageSegmenter *imageSegmenter = [self createImageSegmenterWithOptionsSucceeds:options]; | ||
|
||
MPPImage *image = [MPPImage imageWithFileInfo:kCatImageFileInfo]; | ||
[imageSegmenter segmentImage:image withCompletionHandler:^(MPPImageSegmenterResult *result, NSError *error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't these test need expectation to ensure that these async blocks execute? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. Because the method returns only after the completion handler call completes and hence the test gets completed only after the result is returned via the handler. This segment method is synchronous as opposed to the live stream segment method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, that's right. I will add a comment so future me does not forget again. |
||
[self assertImageSegmenterResult:result | ||
hasConfidenceMasksCount: | ||
kExpectedDeeplabV3ConfidenceMaskCount | ||
approximatelyEqualsExpectedConfidenceMaskImageWithFileInfo:kCatGoldenImageFileInfo | ||
atIndex:8 | ||
shouldHaveCategoryMask:NO]; | ||
}]; | ||
} | ||
|
||
- (void)testSegmentWithNoCopyConfidenceMasksAndVideoModeSucceeds { | ||
MPPImageSegmenterOptions *options = | ||
[self imageSegmenterOptionsWithModelFileInfo:kImageSegmenterModelFileInfo]; | ||
options.runningMode = MPPRunningModeVideo; | ||
|
||
MPPImageSegmenter *imageSegmenter = [self createImageSegmenterWithOptionsSucceeds:options]; | ||
|
||
const NSInteger timestampInMilliseconds = 0; | ||
|
||
MPPImage *image = [MPPImage imageWithFileInfo:kCatImageFileInfo]; | ||
[imageSegmenter segmentVideoFrame:image timestampInMilliseconds:timestampInMilliseconds withCompletionHandler:^(MPPImageSegmenterResult *result, NSError *error) { | ||
[self assertImageSegmenterResult:result | ||
hasConfidenceMasksCount: | ||
kExpectedDeeplabV3ConfidenceMaskCount | ||
approximatelyEqualsExpectedConfidenceMaskImageWithFileInfo:kCatGoldenImageFileInfo | ||
atIndex:8 | ||
shouldHaveCategoryMask:NO]; | ||
}]; | ||
} | ||
|
||
#pragma mark - Image Segmenter Initializers | ||
|
||
- (MPPImageSegmenterOptions *)imageSegmenterOptionsWithModelFileInfo:(MPPFileInfo *)fileInfo { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this method be moved to "Assert Segmenter Results"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get you. This is the delegate method. Is this comment for something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method should be moved out of the section that contains the test methods. I will move it on import.