#include <iostream>
using namespace std;
static void help()
{
cout << "This program demonstrates finding the minimum enclosing box, triangle or circle of a set\n"
<< "of points using functions: minAreaRect() minEnclosingTriangle() minEnclosingCircle().\n"
<< "Random points are generated and then enclosed.\n\n"
<< "Press ESC, 'q' or 'Q' to exit and any other key to regenerate the set of points.\n\n";
}
int main( int , char** )
{
help();
for(;;)
{
int i, count = rng.uniform(1, 101);
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);
}
box.points(vtx);
float radius = 0;
for( i = 0; i < count; i++ )
for( i = 0; i < 4; i++ )
for( i = 0; i < 3; i++ )
imshow(
"Rectangle, triangle & circle", img );
if( key == 27 || key == 'q' || key == 'Q' )
break;
}
return 0;
}
_Tp x
x coordinate of the point
Definition: types.hpp:186
static Scalar_< double > all(double v0)
returns a scalar with all elements set to v0
RNG & theRNG()
Returns the default random number generator.
Point2i Point
Definition: types.hpp:194
Scalar_< double > Scalar
Definition: types.hpp:669
Point_< float > Point2f
Definition: types.hpp:192
#define CV_8UC3
Definition: interface.h:90
int cvRound(double value)
Rounds floating-point number to the nearest integer.
Definition: fast_math.hpp:200
@ triangle
Definition: gr_skig.hpp:63
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
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 circle(InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a circle.
@ LINE_AA
antialiased line
Definition: imgproc.hpp:816
@ FILLED
Definition: imgproc.hpp:813
double minEnclosingTriangle(InputArray points, OutputArray triangle)
Finds a triangle of minimum area enclosing a 2D point set and returns its area.
RotatedRect minAreaRect(InputArray points)
Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
void minEnclosingCircle(InputArray points, Point2f ¢er, float &radius)
Finds a circle of the minimum area enclosing a 2D point set.
"black box" representation of the file storage associated with a file on disk.
Definition: affine.hpp:52