homog2d library
Functions | Variables
showcase1.cpp File Reference

Generates general showcase image. More...

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

Functions

template<typename IM , typename T1 , typename T2 >
void drawIntersect (IM &img, const T1 &t1, const T2 &t2)
 
int main (int, const char **)
 

Variables

DrawParams color_red
 

Detailed Description

Generates general showcase image.

Function Documentation

◆ drawIntersect()

template<typename IM , typename T1 , typename T2 >
void drawIntersect ( IM &  img,
const T1 &  t1,
const T2 &  t2 
)
15 {
16  auto intersect = t1.intersects(t2);
17  if( intersect() )
18  draw( img, intersect.get(), color_red );
19 }
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
DrawParams color_red
Definition: showcase1.cpp:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  ,
const char **   
)
22 {
23  auto nbim = 30; // number of images in gif
24  auto im_w = 400;
25  auto im_h = 280;
26 
27  Image<SvgImage> myImg( im_w, im_h );
28 
29  Homogr Hr( 2.*M_PI/nbim ); // set up rotation
30  Homogr HT1( im_w/2, 100 ); // centered on image center
31  Homogr HT2( -im_w/2, -100 );
32  Homogr H = HT1 * Hr * HT2;
33 
34 // define some primitives
35  Circle cir_fixed( Point2d( 265,195), 40 );
36  Circle cir( Point2d( 32,82), 22 );
37  FRect r_fixed( 40,85,130,155 );
38  Segment seg( 85,210, 335, 25 );
39  FRect rect( 0,0,200,80 );
40  CPolyline pol{ std::vector<Point2d>{ {30,20}, {140,45}, {110,110}, {20,65} } };
41 
42 // define some colors
43  color_red = DrawParams().setColor(200,20,20);
44  auto color_green = DrawParams().setColor(20,220,20);
45  auto color_blue = DrawParams().setColor(20,20,220);
46  auto color_poly = DrawParams().setColor(180,0,180);
47 
48 // move rectangle dx=100, dy=60
49  pol = Homogr().addTranslation(75, 20) * pol;
50  Line2d lih( Point2d(0,100), Point2d(200,100) );
51  Line2d liv( Point2d(200,0), Point2d(200,400) );
52 
53  Line2d li( Point2d(0,0), Point2d(200,80) );
54  for( int i=0; i<nbim; i++ )
55  {
56  myImg.clear();
57 
58  lih.draw( myImg ); // draw all the stuff
59  liv.draw( myImg );
60  li.draw( myImg, color_green );
61  pol.draw( myImg, color_poly );
62 
63  if( cir.isInside( cir_fixed ) || cir.isInside( r_fixed ) )
64  cir.draw( myImg, DrawParams().setColor(220,0,0) );
65  else
66  cir.draw( myImg, color_blue );
67 
68  r_fixed.draw( myImg, color_green );
69  seg.draw( myImg, color_green );
70  cir_fixed.draw( myImg, color_green );
71 
72  drawIntersect( myImg, lih, li );
73  drawIntersect( myImg, lih, seg );
74  drawIntersect( myImg, liv, li );
75  drawIntersect( myImg, liv, seg );
76 
77  drawIntersect( myImg, pol, li );
78  drawIntersect( myImg, pol, r_fixed );
79  drawIntersect( myImg, pol, cir_fixed );
80  drawIntersect( myImg, pol, seg );
81 
82  drawIntersect( myImg, cir, seg );
83  drawIntersect( myImg, cir, r_fixed );
84  drawIntersect( myImg, cir, cir_fixed );
85 
86  std::ostringstream oss;
87  oss << "showcase1_" << std::setfill('0') << std::setw(2) <<i << ".svg";
88  myImg.write( oss.str() );
89 
90  pol = H * pol; // rotate lines and polygon
91  lih = H * lih;
92  liv = H * liv;
93 
94  cir.translate( 12, 6 ); // move the circle
95  }
96 }
A circle.
Definition: homog2d.hpp:378
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
Segment seg
Definition: homog2d_test.cpp:4033
#define M_PI
Definition: homog2d.hpp:235
A 2D homography, defining a planar transformation.
Definition: homog2d.hpp:369
CPolyline pol(5, 5u)
FRect rect
Definition: homog2d_test.cpp:4038
void draw(img::Image< img::SvgImage > &im, img::DrawParams dp=img::DrawParams()) const
SVG draw function.
Definition: homog2d.hpp:4414
auto im_w
Definition: showcase19.cpp:14
void draw(img::Image< cv::Mat > &, img::DrawParams dp=img::DrawParams()) const
Definition: homog2d.hpp:11868
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
void drawIntersect(IM &img, const T1 &t1, const T2 &t2)
Definition: showcase1.cpp:14
Line2d li
Definition: homog2d_test.cpp:4035
auto im_h
Definition: showcase19.cpp:13
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
bool isInside(const Circle_< FPT2 > &other) const
Returns true if circle is inside other circle.
Definition: homog2d.hpp:3403
A Flat Rectangle, modeled by its two opposite points.
Definition: homog2d.hpp:379
Opaque data structure, will hold the image type, depending on back-end library. This type is the one ...
Definition: homog2d.hpp:712
A line segment, oriented (OSegment_) or not (Segment_). Holds the two points.
Definition: homog2d.hpp:366
DrawParams & setColor(uint8_t r, uint8_t g, uint8_t b)
Definition: homog2d.hpp:605
void draw(img::Image< img::SvgImage > &, img::DrawParams dp=img::DrawParams()) const
Draw Polyline (SVG implementation)
Definition: homog2d.hpp:12302
DrawParams color_red
Definition: showcase1.cpp:11
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
void translate(TX dx, TY dy)
Translate Circle.
Definition: homog2d.hpp:3366
Circle cir
Definition: homog2d_test.cpp:4036
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function:

Variable Documentation

◆ color_red

DrawParams color_red