An example using the convexHull functionality
#include <iostream>
using namespace std;
static void help(char** argv)
{
cout << "\nThis sample program demonstrates the use of the convexHull() function\n"
<< "Call:\n"
<< argv[0] << endl;
}
int main( int argc, char** argv )
{
if (parser.has("help"))
{
help(argv);
return 0;
}
for(;;)
{
int i, count = (unsigned)rng%100 + 1;
vector<Point> points;
for( i = 0; i < count; i++ )
{
pt.
x = rng.
uniform(img.cols/4, img.cols*3/4);
pt.
y = rng.
uniform(img.rows/4, img.rows*3/4);
points.push_back(pt);
}
vector<int> hull;
for( i = 0; i < count; i++ )
int hullcount = (int)hull.size();
Point pt0 = points[hull[hullcount-1]];
for( i = 0; i < hullcount; i++ )
{
Point pt = points[hull[i]];
pt0 = pt;
}
if( key == 27 || key == 'q' || key == 'Q' )
break;
}
return 0;
}
int uniform(int a, int b)
returns uniformly distributed integer random number from [a,b) range
void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a line segment connecting two points.
void convexHull(InputArray points, OutputArray hull, bool clockwise=false, bool returnPoints=true)
Finds the convex hull of a point set.
void circle(InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a circle.