An example using the convexHull functionality
#include <iostream>
using namespace cv;
using namespace std;
static void help()
{
cout << "\nThis sample program demonstrates the use of the convexHull() function\n"
<< "Call:\n"
<< "./convexhull\n" << endl;
}
int main( int argc, char** argv )
{
if (parser.has("help"))
{
help();
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;
}