Ask Your Question
0

How to find angle of corners detected?

asked 2014-10-27 01:28:09 -0600

JavaEria gravatar image

updated 2020-11-06 05:27:21 -0600

i want to find angles between the corners detected from a sketched rectangle, i have used harris corner detection and canny edge detection and also have drawn circles around the corners , can i used all of these together to find angles of each corner?

I want to find angles from this image for rectangle classification. image description

I have so far done this: image description

Here is a snippet of code (I have saved the vertices of the drawn circle and want to use it with detected edges from canny):

       cornerHarris( detected_edges, dst, blockSize, apertureSize, k, BORDER_DEFAULT );
       normalize( dst, dst_norm, 0, 255, NORM_MINMAX, CV_32FC1, Mat() );
       convertScaleAbs( dst_norm, dst_norm_scaled );

       /// Drawing a circle around corners
       for( int j = 0; j < dst_norm.rows ; j++ )
       {
         for( int i = 0; i < dst_norm.cols; i++ )
         {
           if( (int) dst_norm.at<float>(j,i) > thresh )
           {
             circle( dst_norm_scaled, Point( i, j ), 5,  Scalar(0), 2, 8, 0 );
         count++;
           }
         }
       }

       vector<Point>* circle_points;  
       circle_points= new vector<Point>[count];
       int pt=0;
       for( int j = 0; j < dst_norm.rows ; j++ )
       {
         for( int i = 0; i < dst_norm.cols; i++ )
         {
            if( (int) dst_norm.at<float>(j,i) > thresh )
            {
               ellipse2Poly( Point(i,j), axes, 0, 0, 360, 1, circle_points[pt] ); 
               pt++;
            }
         }
       }
edit retag flag offensive close merge delete

Comments

Can you please add screen shots of what exactly you get in the input and output ?

itay gravatar imageitay ( 2014-10-27 06:46:24 -0600 )edit

I edited my question just now

JavaEria gravatar imageJavaEria ( 2014-10-27 07:44:01 -0600 )edit

I m also new to opencv , and i m tryng to find these points, this is a snippet after corner and canny detection

circle_points= new vector<Point>[count];

int pt=0;

for( int j = 0; j < dst_norm.rows ; j++ )

 {

      for( int i = 0; i &lt; dst_norm.cols; i++ )
      {
           if( (int) dst_norm.at&lt;float&gt;(j,i) &gt; thresh )
          {
             ellipse2Poly( Point(i,j), axes, 0, 0, 360, 1, circle_points[pt] ); 
              pt++;
           }
      }

 }
JavaEria gravatar imageJavaEria ( 2014-10-27 08:51:46 -0600 )edit

Please, Edit your code in your answer to make it readable.

itay gravatar imageitay ( 2014-10-27 09:08:45 -0600 )edit

Sorry for that , i have edited the code

JavaEria gravatar imageJavaEria ( 2014-10-27 10:51:50 -0600 )edit

I think this answer could help you to find the other points how to find the coordinate of top/bottom/left and right points

itay gravatar imageitay ( 2014-10-28 01:38:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-10-27 08:38:02 -0600

itay gravatar image

updated 2014-10-27 08:52:31 -0600

First, you have to find 3 points.

So for this I'll suggest first to select first the angle you want to check and than take the position of the near vertex(This will be your first point). You can give this point the value of(0,0) Origin of the coordinate.

Now you know that there is 2 lines go out from this point. find the coordinate of the most far pixel from this point By X and Y.

For example if I look for the top left corner (My origin) I search the most right pixel coordinate(Second point) and the most bottom pixel coordinate(Third point).

Now you have 3 point, So you can find the angle using this topic Hope it solved your problem.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-10-27 01:28:09 -0600

Seen: 3,447 times

Last updated: Oct 27 '14