convex-hull

Convexity defects C++ OpenCv

痴心易碎 提交于 2019-11-26 13:54:29
问题 I would be grateful to you if you could help me with this issue :) Relating to this question cvConvexityDefects in OpenCV 2.X / C++?, I have the same problem. The OpenCV C++ wrapper has not the function cvConvexityDefects that appears in the C version, so I tried to write my own version. Part of the code is (please note that both countour and hull are vector< Point >, calculated separately : CvSeq* contourPoints; CvSeq* hullPoints; CvSeq* defects; CvMemStorage* storage; CvMemStorage*

Create non-intersecting polygon passing through all given points

旧城冷巷雨未停 提交于 2019-11-26 13:03:42
问题 Suppose I have an array of points in random order, and I need to find a polygon (by sorting them, such that every adjacent pair represents a side) which passes through all of the points, and its sides are non-intersecting of course. I tried to do it by selecting a point, and adding all points to the final array which are below it, sorted left to right. Then, adding all points which are above it, sorted right to left. I\'ve been told that I can add an additional point and sort naturally to

How to tell whether a point is to the right or left side of a line

不问归期 提交于 2019-11-26 07:49:38
问题 I have a set of points. I want to separate them into 2 distinct sets. To do this, I choose two points ( a and b ) and draw an imaginary line between them. Now I want to have all points that are left from this line in one set and those that are right from this line in the other set. How can I tell for any given point z whether it is in the left or in the right set? I tried to calculate the angle between a-z-b – angles smaller than 180 are on the right hand side, greater than 180 on the left

How to tell whether a point is to the right or left side of a line

筅森魡賤 提交于 2019-11-26 01:42:53
问题 I have a set of points. I want to separate them into 2 distinct sets. To do this, I choose two points ( a and b ) and draw an imaginary line between them. Now I want to have all points that are left from this line in one set and those that are right from this line in the other set. How can I tell for any given point z whether it is in the left or in the right set? I tried to calculate the angle between a-z-b – angles smaller than 180 are on the right hand side, greater than 180 on the left