Skip to content

fixed the ordering of contour convex hull points#16594

Merged
alalek merged 7 commits intoopencv:3.4from
vpisarev:hull_ordering_fix
Feb 21, 2020
Merged

fixed the ordering of contour convex hull points#16594
alalek merged 7 commits intoopencv:3.4from
vpisarev:hull_ordering_fix

Conversation

@vpisarev
Copy link
Copy Markdown
Contributor

@vpisarev vpisarev commented Feb 16, 2020

Fixes issue #14521.
Partially fixes the issue #4539.

  1. if possible, the convex hull indices are "rotated" to form a monotonous sequence, decreasing or increasing.
  2. added the check to convexityDefects to check that the indices are monotonous; if not, an exception is thrown
  3. added the test from Indices from convexHull not monotonic #4539 discussion with a workaround (to eliminate the contour self-intersection). With this workaround everything works well.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Tests should be simple and clear as much as possible.

Mat canvas_gray(Size(60*scale, 45*scale), CV_8U, Scalar::all(0));
fillConvexPoly(canvas_gray, contour_.ptr<Point>(), npoints, Scalar(255, 255, 255));

#if 1 // try to eliminate the self-intersection in one way or another
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we not test input "as is"?
Why do we need these hacks with preparation of input before calling of testing functions?
Why is original input considered as invalid and it requires such processing?

Suggested input comes from somewhere and should be processed in its original form - instead of drawing, dilating and finding contours.

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.

ok, I added the code to test the original contour

…n convexHull and convexityDetects on the original contour, without any manipulations. the rest of the test stays the same
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@alalek alalek merged commit 8f38677 into opencv:3.4 Feb 21, 2020
jshiwam pushed a commit to jshiwam/opencv that referenced this pull request Feb 22, 2020
fixed the ordering of contour convex hull points

* partially fixed the issue opencv#4539

* fixed warnings and test failures

* fixed integer overflow (issue opencv#14521)

* added comment to force buildbot to re-run

* extended the test for the issue 4539. Check the expected behaviour on the original contour as well

* added comment; fixed typo, renamed another variable for a little better clarity

* added yet another part to the test for issue opencv#4539, where we run convexHull and convexityDetects on the original contour, without any manipulations. the rest of the test stays the same
jshiwam added a commit to jshiwam/opencv that referenced this pull request Feb 22, 2020
…m added

dnn: don't require setInput in .dump()

dnn: auto network dump through parameter

Improved GStreamer documentation.

improved documentation for imread()

videoio/MSMF: refactored format handling and selection, property reading and writing

dnn(test): skip failed ngraph tests

add cuda 10 support

3.4 docs for 3.4 branch

Resolve opencv#14566

Merge pull request opencv#16445 from atinfinity:fixed-typo

* fixed typo

* add compatibility code to handle migration

Enable Mask R-CNN with Inference Engine. Full coverage with nGraph

intrin: fixed int64->double conversion for AVX-512

Merge pull request opencv#16608 from vpisarev:fix_mac_ocl_tests

* fixed several problems when running tests on Mac:
* OCL_pyrUp
* OCL_flip
* some basic UMat tests
* histogram badarg test (out of range access)

* retained the storepix fix in ocl_flip only for 16U/16S datatype, where the OpenCL compiler on Mac generates incorrect code

* moved deletion of ACCESS_FAST flag to non-SVM branch (where SVM is shared virtual memory (in OpenCL 2.x), not support vector machine)

* force OpenCL to use read/write for GPU<=>CPU memory transfers on machines with discrete video only on Macs. On Windows/Linux the drivers are seemingly smart enough to implement map/unmap properly (and maybe more efficiently than explicit read/write)

Merge pull request opencv#16594 from vpisarev:hull_ordering_fix

fixed the ordering of contour convex hull points

* partially fixed the issue opencv#4539

* fixed warnings and test failures

* fixed integer overflow (issue opencv#14521)

* added comment to force buildbot to re-run

* extended the test for the issue 4539. Check the expected behaviour on the original contour as well

* added comment; fixed typo, renamed another variable for a little better clarity

* added yet another part to the test for issue opencv#4539, where we run convexHull and convexityDetects on the original contour, without any manipulations. the rest of the test stays the same
@alalek alalek mentioned this pull request Feb 26, 2020
@vpisarev vpisarev deleted the hull_ordering_fix branch May 28, 2020 18:20
increasing_idx = !(hcurr < hnext);
else if( increasing_idx != (hcurr < hnext))
{
CV_Error(Error::StsBadArg,
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please provide complete minimal reproducer and fill an issue in opencv_contrib.

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.

integer overflow in convexHull

3 participants