Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can create a Point2f (2 dimensions float) in the center of each of the smaller sides of your rectangle:

o o x o o  ---> x = point_a
 o o o o
  o o o
   o o
    x      ---> x = point_b

(Above, "x" represents the points). And then:

double rad_angle = atan(point_a/point_b);

It will generate the angle in rads, If you want the angle in degrees

double degrees_angle * 180/CV_PI;

Cheers!

You can create a Point2f (2 dimensions float) in the center of each of the smaller sides of your rectangle:

o o x o o  ---> x = point_a
 o o o o
  o o o
   o o
    x      ---> x = point_b

(Above, "x" represents the points). And then:

double rad_angle = atan(point_a/point_b);

It will generate the angle in rads, If you want the angle in degrees

double degrees_angle = rad_angle * 180/CV_PI;

Cheers!

You can could create a Point2f (2 dimensions float) in the center of each of the smaller sides of your rectangle:

o o x o o  ---> x = point_a
 o o o o
  o o o
   o o
    x      ---> x = point_b

(Above, "x" represents the points). And then:

double rad_angle = atan(point_a/point_b);

It will generate the angle in rads, If you want the angle in degrees

double degrees_angle = rad_angle * 180/CV_PI;

Cheers!

You could create a Point2f (2 dimensions float) in the center of each of the smaller sides of your rectangle:

o o x o o  ---> x = point_a
 o o o o
  o o o
   o o
    x      ---> x = point_b

(Above, "x" represents the points). And then:This way, you will get a line between those points:

o   x   o  
 o  |  o
  o | o
   o|o
    x

To calculate that line angle in radians:

double rad_angle = atan(point_a/point_b);

It will generate the angle in rads, If you want the angle in degreesdegrees:

double degrees_angle = rad_angle * 180/CV_PI;

Cheers!