homog2d library
Functions | Variables
showcase12.cpp File Reference

demo of full steps rotating of a Polyline (2022-11-06: WIP !!) More...

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

Functions

int main (int, const char **)
 
void processRot (CPolyline &pl, std::string msg, Rotate rot, int nb_img, int pt_idx)
 

Variables

img::Image< img::SvgImageim (300, 400)
 

Detailed Description

demo of full steps rotating of a Polyline (2022-11-06: WIP !!)

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
48 {
49  CPolyline pl;
50  std::vector<Point2d> vpts{
51  { 5,5 },
52  { 7,3 },
53  { 6, 2 },
54  { 7.5, 1. },
55  { 4, 0 },
56  { 5.5, 2.5 },
57  { 4., 1.2 },
58  { 3., 2.2 },
59  { 3.6, 4.1 },
60  { 1.6, 5.4 }
61  };
62  pl.set( vpts );
63 
64  auto Hdraw = Homogr().setScale(30).addTranslation(10,30);
65 
66  int nbpts = 3;
67  auto pl2 = Hdraw * pl;
68  processRot( pl2, "VMirror", Rotate::VMirror, nbpts, 0 );
69  processRot( pl2, "HMirror", Rotate::HMirror, nbpts, 0 );
70  processRot( pl2, "ClockWise", Rotate::CW, 5, 0 );
71  processRot( pl2, "CClockWise", Rotate::CCW, 5, 0 );
72  processRot( pl2, "Full", Rotate::Full, nbpts, 0 );
73 }
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
void processRot(CPolyline &pl, std::string msg, Rotate rot, int nb_img, int pt_idx)
Definition: showcase12.cpp:13
void set(const CONT &vec)
Set from vector/array/list of points (discards previous points)
Definition: homog2d.hpp:6461
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Here is the call graph for this function:

◆ processRot()

void processRot ( CPolyline pl,
std::string  msg,
Rotate  rot,
int  nb_img,
int  pt_idx 
)
Parameters
plPolyline
rotWhat kind of rotation?
nb_imgHow many images
pt_idxindex of Polyline point that will be the center point
20 {
21  static int out_idx;
22  for( int i=0; i<nb_img; i++ )
23  {
24  im.clear();
25 #if 0
26  cv::putText(
27  im.getReal(),
28  std::to_string(out_idx) + ": " + msg + ": " + std::to_string(i+1) + "/" + std::to_string(nb_img),
29  cv::Point2i( 20, 40 ), 0, 0.6, cv::Scalar( 50,0,0 ), 1
30  );
31 #else
32  drawText( im, std::to_string(out_idx) + ": " + msg + ": " + std::to_string(i+1) + "/" + std::to_string(nb_img), Point2d(20,40) );
33 #endif
34  pl.rotate( rot, pl.getPoint(pt_idx) );
35  pl.getPoint(0).draw( im, img::DrawParams().setColor(250,120,20).setPointStyle(img::PtStyle::Diam) );
36  draw( im, Line2d( LineDir::H, pl.getPoint(0) ), img::DrawParams().setColor(200,200,200) );
37  draw( im, Line2d( LineDir::V, pl.getPoint(0) ), img::DrawParams().setColor(200,200,200) );
38  pl.draw( im, img::DrawParams().setColor(250,0,20) );
39 // pl.getBB().draw( im, img::DrawParams().setColor(150,150,120) );
40 
41  std::ostringstream oss;
42  oss << "showcase12_" << std::setfill('0') << std::setw(2) << out_idx++ << ".svg";
43  im.write( oss.str() );
44  }
45 }
Point2d_< FPT > getPoint(size_t idx) const
Returns one point of the polyline.
Definition: homog2d.hpp:6320
void drawText(img::Image< U > &im, std::string str, Point2d_< FPT > pt, img::DrawParams dp=img::DrawParams())
Free function, draws text str at position pt.
Definition: homog2d.hpp:11260
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12376
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
void rotate(Rotate, const Point2d_< FPT2 > &)
Rotates the polyline by either 90°, 180°, 270° (-90°) at point refpt.
Definition: homog2d.hpp:7265
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
img::Image< img::SvgImage > im(300, 400)
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
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ im

img::Image<img::SvgImage> im(300, 400)