Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Orientation of two contours

I try to calculate the orientation of 2 contours. At the end i want to rotate one contour, so it is in cover with the other one. With my code I get a result, but it isn't that accurate. Also I get the same orientations although the contours is rotated around 90 degrees.

Here is my code:

   double PI = 3.14159;
   Moments moments_dxf;
   Moments moments_img;


   moments_dxf = moments( mcontours_dxf[ alargest_contour_index_dxf ], true );
   double theta_dxf_outer = 0.5 * atan( ( 2 * moments_dxf_outer.mu11 ) / ( moments_dxf_outer.mu20 - moments_dxf_outer.mu02 ) );

   moments_img = moments( mcontours_image[ alargest_contour_index_img ], true );
   double theta_img_outer = 0.5 * atan( ( 2 * moments_img_outer.mu11 ) / ( moments_img_outer.mu20 - moments_img_outer.mu02 ) );

has anyone an idea?

Orientation of two contours

I try to calculate the orientation of 2 contours. At the end i want to rotate one contour, so it is in cover with the other one. With my code I get a result, but it isn't that accurate. Also I get the same orientations although the contours is rotated around 90 degrees.

Here is my code:

 double PI = 3.14159;
   Moments moments_dxf;
   Moments moments_img;
 
   moments_dxf = moments( mcontours_dxf[ alargest_contour_index_dxf ], true );
   double theta_dxf_outer = 0.5 * atan( ( 2 * moments_dxf_outer.mu11 ) / ( moments_dxf_outer.mu20 - moments_dxf_outer.mu02 ) );

   moments_img = moments( mcontours_image[ alargest_contour_index_img ], true );
   double theta_img_outer = 0.5 * atan( ( 2 * moments_img_outer.mu11 ) / ( moments_img_outer.mu20 - moments_img_outer.mu02 ) );

has anyone an idea?

Orientation of two contours

I try to calculate the orientation of 2 contours. At the end i want to rotate one contour, so it is in cover with the other one. With my code I get a result, but it isn't that accurate. Also I get the same orientations although the contours is rotated around 90 degrees.

Here is my code:

   Moments moments_dxf;
   Moments moments_img;

   moments_dxf = moments( mcontours_dxf[ alargest_contour_index_dxf ], true );
   double theta_dxf_outer = 0.5 * atan( ( 2 * moments_dxf_outer.mu11 ) / ( moments_dxf_outer.mu20 - moments_dxf_outer.mu02 ) );

   moments_img = moments( mcontours_image[ alargest_contour_index_img ], true );
   double theta_img_outer = 0.5 * atan( ( 2 * moments_img_outer.mu11 ) / ( moments_img_outer.mu20 - moments_img_outer.mu02 ) );

has anyone an idea?

Orientation of two contours

I try to calculate the orientation of 2 contours. At the end i want to rotate one contour, so it is in cover with the other one. With my code I get a result, but it isn't that accurate. Also I get the same orientations although the contours is rotated around 90 degrees.

Here is my code:

   Moments moments_dxf;
   Moments moments_img;

   moments_dxf = moments( mcontours_dxf[ alargest_contour_index_dxf ], true );
   double theta_dxf_outer = 0.5 * atan( ( 2 * moments_dxf_outer.mu11 ) / ( moments_dxf_outer.mu20 - moments_dxf_outer.mu02 ) );

   moments_img = moments( mcontours_image[ alargest_contour_index_img ], true );
   double theta_img_outer = 0.5 * atan( ( 2 * moments_img_outer.mu11 ) / ( moments_img_outer.mu20 - moments_img_outer.mu02 ) );

has anyone an idea?