The function which returns the angle of curvature of the object Opencv C++

asked 2014-03-13 11:36:15 -0600

zowpro gravatar image

updated 2014-03-13 11:46:22 -0600

Hello, i'm searching a function in Opencv which returns the angle of a specific object on image from its contour points or points of its related envelope. Exemple: !image description

edit retag flag offensive close merge delete

Comments

Does the image change shape or size? The first step is to use one of the object detectors. If you are generating the shape and it's BW you could use an average of the X and Y of all the black pixels to find it's center and then take the average of x and y for all the black pixels that are in the 4 quadrants from the center to get the rotation.

GrumbleLion gravatar imageGrumbleLion ( 2014-03-14 13:59:48 -0600 )edit

The object or the image has the same size and for the detection, i used findcontours() and ApproxpolyDP to find the contours points and i got the gravity center

zowpro gravatar imagezowpro ( 2014-03-15 04:05:03 -0600 )edit

ok... then to get the rotation you can create a weighted filter. or for a crude value you could find the points that are farthest from the center.

GrumbleLion gravatar imageGrumbleLion ( 2014-03-21 20:20:51 -0600 )edit