homog2d library
Functions
showcase2a.cpp File Reference

Generates area of intersection of two rectangles. More...

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

Functions

int main (int, const char **)
 

Detailed Description

Generates area of intersection of two rectangles.

Function Documentation

◆ main()

int main ( int  ,
const char **   
)
13 {
14  int n=30;
15  auto im_w = 350;
16  auto im_h = 180;
18 
19  FRect r1(40,30, 130,90 );
20  FRect r2(160,45, 210,150 );
21 
22  auto color_red = DrawParams().setColor(200,20,20);
23  auto color_green = DrawParams().setColor(20,220,20);
24  int mul = 1;
25  for( int i=0; i<n; i++ )
26  {
27  imga.clear();
28  getBB(r1,r2).draw( imga, DrawParams().setColor(200,200,200) );
29 
30  r1.draw( imga, color_green );
31  r2.draw( imga, color_green );
32 
33 #if 0 // either way is the same
34  auto a = r1.intersectArea(r2);
35 #else
36  auto a = r1&r2;
37 #endif
38 
39  if( a() )
40  a.get().draw( imga, color_red );
41  imga.drawText( "IoU=" + std::to_string( IoU(r1,r2) ), Point2d (20,20) );
42 
43  if( (i+1)%10 == 0 )
44  {
45  mul = mul*-1;
46  r1.translate(0,30);
47  }
48  std::ostringstream ossa;
49  ossa << "showcase2a_" << std::setfill('0') << std::setw(2) <<i << ".svg";
50  imga.write( ossa.str() );
51 
52 
53  r1.translate( mul*20,0);
54  }
55 
56 }
HOMOG2D_INUMTYPE IoU(const FRect_< FPT1 > &r1, const FRect_< FPT2 > &r2)
Intersection area over Union area (free function)
Definition: homog2d.hpp:9856
auto im_w
Definition: showcase19.cpp:14
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
auto im_h
Definition: showcase19.cpp:13
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
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
DrawParams color_red
Definition: showcase1.cpp:11
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function: