imgproc: add contour values check to IntelligentScissorsMB tests#23688
imgproc: add contour values check to IntelligentScissorsMB tests#23688asmorkalov merged 8 commits intoopencv:4.xfrom
Conversation
The failed tests seemed to be only for some tests on some platforms with small differences between the actual and the reference contour. Therefore the latest commit adds epsilon logic for the contour values check where there is epsilon logic already for the contour size check. |
…pute_full_local_cost flag;
| else if (pts.size() == reference_pts.size()) | ||
| { | ||
| for (size_t idx = 0; idx < reference_pts.size(); ++idx) | ||
| { | ||
| EXPECT_GE(pts[idx].x, reference_pts[idx].x - PTS_EPS); | ||
| EXPECT_GE(pts[idx].y, reference_pts[idx].y - PTS_EPS); | ||
| EXPECT_LE(pts[idx].x, reference_pts[idx].x + PTS_EPS); | ||
| EXPECT_LE(pts[idx].y, reference_pts[idx].y + PTS_EPS); | ||
| } |
There was a problem hiding this comment.
Else branch looks strange. It checks nothing, if size is different. In case if +-1 result is expected, then you can use cv::norm(..., NORM_INF) could be used. In case if amount of contour pixels is unstable, please do not call getContours, but do all steps in test body.
There was a problem hiding this comment.
Thanks for the cv::norm(..., NORM_INF) suggestion!
I'm not sure if I understood the "... but do all steps in test body." suggestion correctly, did you mean something this?
double getContour(segmentation::IntelligentScissorsMB& tool,
const Point& target_point, std::vector<Point>& pts, const bool backward = false)
{
...
return cv::norm(pts, reference_pts, cv::NORM_INF);
}
...
EXPECT_EQ(getContour(tool, target_point, pts), 0);
...
EXPECT_LE(getContour(tool, target_point, pts), PTS_EPS);
...
There was a problem hiding this comment.
... I'm not sure if I understood the "... but do all steps in test body." suggestion correctly ...
Never mind, I see now e.g. from the https://pullrequest.opencv.org/buildbot/builders/precommit_windows64/builds/101746/steps/test_imgproc/logs/tests%20summary CI failure that the cv::norm call should only be made if the vector sizes match and therefore the call is better placed in the test body alongside the PTS_SIZE_EPS check.
The 1 failing seems to be unrelated to the changes in this PR. |
| tool.getContour(target_point, pts2, true/*backward*/); | ||
| getAndCheckContour(tool, target_point, pts2, true/*backward*/); | ||
|
|
||
| EXPECT_EQ(pts.size(), pts2.size()); |
There was a problem hiding this comment.
getAndCheckContour checks contour size too. The following size checks are not required here and bellow.
|
@cpoerschke Thanks a lot for the tests. I reworked them a bit to check contour area, but not contour pixels. It allows to compare cases, when contour does not match exactly. Please take a look on the solution and let me know, if you agree on it. |
|
Hm.. Github does not show my last commit by some reason. Could you cherry-pick it from my branch: https://github.com/asmorkalov/opencv/commits/4.x-pr-21959-prep |
Thanks @asmorkalov for the reworked test to check the contour area and not just the contour pixels! LGTM.
Hmm, very strange, the commit was there on my branch (as expected since allow-edits-by-maintainers is checked for this PR) but github did not show it. Anyhow, I've pushed a commit with three small style tweaks and that resynced things then apparently. |
imgproc: add contour values check to IntelligentScissorsMB tests Preparation for the opencv#21959 changes as per @asmorkalov's opencv#21959 (comment) suggestion. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
imgproc: add contour values check to IntelligentScissorsMB tests Preparation for the opencv#21959 changes as per @asmorkalov's opencv#21959 (comment) suggestion. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
imgproc: add contour values check to IntelligentScissorsMB tests Preparation for the opencv#21959 changes as per @asmorkalov's opencv#21959 (comment) suggestion. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
Preparation for the #21959 changes as per @asmorkalov's #21959 (comment) suggestion.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.