homog2d library
Macros | Enumerations | Functions | Variables
precision_test_opencv.cpp File Reference
#include "homog2d.hpp"
#include "opencv2/highgui.hpp"
#include <functional>
Include dependency graph for precision_test_opencv.cpp:

Macros

#define HOMOG2D_USE_OPENCV
 
#define NUMTYPE   long double
 

Enumerations

enum  Order {
  Order::RST, Order::RTS, Order::TSR, Order::TRS,
  Order::STR, Order::SRT, Order::Dummy, Order::RST,
  Order::RTS, Order::TSR, Order::TRS, Order::STR,
  Order::SRT, Order::Dummy
}
 

Functions

void draw (Data &data)
 
const char * getString (Order order)
 
int main (int argc, const char **argv)
 
void mouse_CB (int event, int x, int y, int, void *params)
 Mouse callback function, checks if one of the points is selected. More...
 
std::ostream & operator<< (std::ostream &f, const Data &data)
 

Variables

int g_height = 500
 
int g_width = 600
 
std::string g_wndname = "homog2d demo"
 

Macro Definition Documentation

◆ HOMOG2D_USE_OPENCV

#define HOMOG2D_USE_OPENCV

◆ NUMTYPE

#define NUMTYPE   long double

Enumeration Type Documentation

◆ Order

enum Order
strong
Enumerator
RST 
RTS 
TSR 
TRS 
STR 
SRT 
Dummy 
RST 
RTS 
TSR 
TRS 
STR 
SRT 
Dummy 

Function Documentation

◆ draw()

void draw ( Data &  data)
185 {
186  data.img = cv::Scalar(255,255,255);
187 
188  data.line1.draw( data.img, CvDrawParams().setColor( 0, 0, 250) );
189  data.line2.draw( data.img, CvDrawParams().setColor( 0, 250, 0) );
190  Segment seg( data.vpt[0], data.pt );
191  seg.draw( data.img, CvDrawParams().setColor( 50, 50, 50) );
192  data.vpt[0].draw( data.img, CvDrawParams().setColor( 250, 50, 0) );
193  data.vpt[1].draw( data.img, CvDrawParams().setColor( 0, 50, 250) );
194 
195  cv::imshow( g_wndname, data.img );
196 }
Segment seg
Definition: homog2d_test.cpp:4033
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
std::string g_wndname
Definition: precision_test_opencv.cpp:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getString()

const char* getString ( Order  order)
47 {
48  switch (order )
49  {
50  case Order::RST: return "RST";
51  case Order::RTS: return "RRS";
52  case Order::TSR: return "TSR";
53  case Order::TRS: return "TRS";
54  case Order::STR: return "STR";
55  case Order::SRT: return "SRT";
56  default: assert(0);
57  }
58 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
const char **  argv 
)
257 {
258  Data data;
259  cv::namedWindow( g_wndname );
260  data.img.create( g_height, g_width, CV_8UC3 );
261 
262  data.computeH();
263  data.process();
264 
265  cv::imshow( g_wndname, data.img );
266  cv::setMouseCallback( g_wndname, mouse_CB, &data );
267 
268  char key=0;
269  while( key != 27 ) // SPC
270  {
271  bool changed = true;
272  switch( key = cv::waitKey(0) )
273  {
274  case 'm': data.angle(1); break;
275  case 'l': data.angle(0); break;
276 
277  case 'o': data.scale(1); break;
278  case 'p': data.scale(0); break;
279 
280  case 'g': data.translate(0); break;
281  case 'h': data.translate(1); break;
282  case ' ': data.changeOrder(); break;
283  default: changed = false; break;
284  }
285  if( changed )
286  {
287  data.computeH();
288  data.process();
289  std::cout << data << '\n';
290  }
291  cv::imshow( g_wndname, data.img );
292  }
293 }
int g_width
Definition: precision_test_opencv.cpp:38
std::string g_wndname
Definition: precision_test_opencv.cpp:36
int g_height
Definition: precision_test_opencv.cpp:39
void mouse_CB(int event, int x, int y, int, void *params)
Mouse callback function, checks if one of the points is selected.
Definition: precision_test_opencv.cpp:218
Here is the call graph for this function:

◆ mouse_CB()

void mouse_CB ( int  event,
int  x,
int  y,
int  ,
void *  params 
)

Mouse callback function, checks if one of the points is selected.

  • If so, that point gets moved by the mouse
219 {
220  Data* p_data = reinterpret_cast<Data*>(params);
221  draw( *p_data );
222 
223  p_data->setMousePos(x,y);
224 
225  switch( event )
226  {
227  case CV_EVENT_LBUTTONUP:
228  p_data->selected = -1;
229  break;
230 
231  case CV_EVENT_LBUTTONDOWN:
232  for( int i=0; i<2; i++ )
233  if( p_data->pt_mouse.distTo( p_data->vpt[i]) < 10 ) // if mouse is less than 10 pixel away
234  p_data->selected = i;
235  break;
236 
237  case CV_EVENT_MOUSEMOVE:
238  {
239  if( p_data->selected != -1 )
240  {
241  p_data->vpt[p_data->selected] = p_data->pt_mouse;
242  p_data->process();
243 // auto d = p_data->computeDistTransformedLined();
244 // std::cout << "d=" << (d==0. ? d : std::log10(d)) << '\n';
245  }
246  }
247  break;
248 
249  default: break;
250  }
251  cv::imshow( g_wndname, p_data->img );
252 }
void draw(Data &data)
Definition: precision_test_opencv.cpp:184
std::string g_wndname
Definition: precision_test_opencv.cpp:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<()

std::ostream& operator<< ( std::ostream &  f,
const Data &  data 
)
161 {
162  f << "order=" << getString( data.order )
163  << " rotation=" << data._angle
164  << " scale=(" << data._sx << "," << data._sy << ") "
165  << " translation=(" << data._tx << "," << data._ty << ") "
166  << '\n';
167  return f;
168 }
const char * getString(Order order)
Definition: precision_test_opencv.cpp:46
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_height

int g_height = 500

◆ g_width

int g_width = 600

◆ g_wndname

std::string g_wndname = "homog2d demo"