Skip to content

imgproc: add contour values check to IntelligentScissorsMB tests#23688

Merged
asmorkalov merged 8 commits intoopencv:4.xfrom
cpoerschke:4.x-pr-21959-prep
Jun 7, 2023
Merged

imgproc: add contour values check to IntelligentScissorsMB tests#23688
asmorkalov merged 8 commits intoopencv:4.xfrom
cpoerschke:4.x-pr-21959-prep

Conversation

@cpoerschke
Copy link
Copy Markdown
Contributor

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

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • 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

@cpoerschke
Copy link
Copy Markdown
Contributor Author

5 failing, 14 successful, 1 skipped, and 1 errored checks

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.

cpoerschke added a commit to cpoerschke/opencv that referenced this pull request May 26, 2023
Comment on lines +179 to +187
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);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... 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.

@cpoerschke cpoerschke marked this pull request as draft May 27, 2023 20:10
@cpoerschke cpoerschke marked this pull request as ready for review May 27, 2023 22:28
@cpoerschke
Copy link
Copy Markdown
Contributor Author

19 successful, 1 failing, and 1 skipped checks

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());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAndCheckContour checks contour size too. The following size checks are not required here and bellow.

@cpoerschke cpoerschke marked this pull request as draft May 29, 2023 10:07
@cpoerschke cpoerschke marked this pull request as ready for review May 29, 2023 20:57
@cpoerschke cpoerschke requested a review from asmorkalov June 4, 2023 07:31
@asmorkalov
Copy link
Copy Markdown
Contributor

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

@asmorkalov
Copy link
Copy Markdown
Contributor

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

@asmorkalov asmorkalov self-requested a review June 6, 2023 13:05
@cpoerschke
Copy link
Copy Markdown
Contributor Author

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

Thanks @asmorkalov for the reworked test to check the contour area and not just the contour pixels! LGTM.

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

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.

Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov merged commit d3e7968 into opencv:4.x Jun 7, 2023
@asmorkalov asmorkalov mentioned this pull request Jul 12, 2023
advait-0 pushed a commit to advait-0/opencv that referenced this pull request Aug 31, 2023
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
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
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
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants