How to find angle of corners detected?

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. I have so far done this: 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 close merge delete

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

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++;
}
}

}

Sort by » oldest newest most voted

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.

more

Stats

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

Seen: 1,932 times

Last updated: Oct 27 '14