homog2d library
Functions
showcase13.cpp File Reference

Generates random points, the Convex Hull, the Bounding Box, the Minimum Enclosing Circle (MEC), and the extremum points. More...

#include "../../homog2d.hpp"
Include dependency graph for showcase13.cpp:

Functions

int main (int, const char **)
 

Detailed Description

Generates random points, the Convex Hull, the Bounding Box, the Minimum Enclosing Circle (MEC), and the extremum points.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
12 {
13  auto nbim = 20; // nb images
14 
15  auto cmax = 250;
16  auto cmin = 50;
17  auto nbpts_max = 50;
18  auto nbpts_min = 5;
19 
20  auto extr_col = img::DrawParams().setColor(100,250,0).setPointStyle( img::PtStyle::Dot );
21  for( int i=0; i<nbim; i++ )
22  {
23  img::Image<img::SvgImage> im( cmax+30, cmax+30 );
24  int nbpts = 1.0*rand() / RAND_MAX * (nbpts_max-nbpts_min) + nbpts_min;
25  std::vector<Point2d> vec(nbpts);
26  auto it = std::begin(vec);
27  for( auto j=0; j<nbpts; j++ )
28  *it++ = Point2d(
29  1.0*rand() / RAND_MAX * (cmax-cmin) + cmin,
30  1.0*rand() / RAND_MAX * (cmax-cmin) + cmin
31  );
32  auto ch = convexHull( vec );
33  draw( im, vec );
34  ch.draw( im, img::DrawParams().setColor(250,100,100) );
35  getBB(vec).draw( im, img::DrawParams().setColor(100,100,250) );
36 
37  Circle cir;
38  cir.set( vec ); // Minimum Enclosing Circle (MEC)
39  cir.draw( im, img::DrawParams().setColor(0,100,150) );
40 
41  getTmPoint(vec).first.draw( im, extr_col );
42  getRmPoint(vec).first.draw( im, extr_col );
43  getLmPoint(vec).first.draw( im, extr_col );
44  getBmPoint(vec).first.draw( im, extr_col );
45 
46  std::ostringstream oss;
47  oss << "showcase13_" << std::setfill('0') << std::setw(2) << i << ".svg";
48  im.write( oss.str() );
49  }
50 }
A circle.
Definition: homog2d.hpp:378
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
auto getBmPoint(const T &t)
Return Bottom-most point of container holding points.
Definition: homog2d.hpp:6915
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
void draw(img::Image< cv::Mat > &, img::DrawParams=img::DrawParams()) const
Draw Circle (Opencv implementation)
Definition: homog2d.hpp:11907
auto getTmPoint(const T &t)
Return Top-most point of container.
Definition: homog2d.hpp:6940
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
void set(const Point2d_< PT > &center)
Set circle center point, radius unchanged.
Definition: homog2d.hpp:3297
img::Image< img::SvgImage > im(300, 400)
DrawParams & setPointStyle(PtStyle ps)
Definition: homog2d.hpp:585
auto getLmPoint(const T &t)
Return Left-most point of container as a pair holding:
Definition: homog2d.hpp:6987
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
auto getRmPoint(const T &t)
Return Right-most point of container holding points.
Definition: homog2d.hpp:7028
CPolyline_< FPT > convexHull(const base::PolylineBase< CT, FPT > &input)
Compute Convex Hull of a Polyline (free function)
Definition: homog2d.hpp:11536
FRect_< HOMOG2D_INUMTYPE > getBB(const T &t)
Return Bounding Box of primitive or container holding primitives (free function)
Definition: homog2d.hpp:10312
DrawParams & setColor(uint8_t r, uint8_t g, uint8_t b)
Definition: homog2d.hpp:605
Circle cir
Definition: homog2d_test.cpp:4036
Here is the call graph for this function: