how to find angle from x y points?

I have image which contain 12 center point of rectangle. I am not getting how to code for image rotation from that point.C:\fakepath\deskew.png.Please help me with some code in opencv and python

edit retag close merge delete

Sort by ยป oldest newest most voted

Take 12 points, find minAreaRect, angle of this rect will be your rotation angle, then find rotation matrix and apply rotation

more

i have to first save this center points of rectangle in one variable then i can pass that variable inside minAreaRect. Is it r8?

( 2016-12-28 23:35:03 -0500 )edit

rect = cv2.minAreaRect(points) box = cv2.cv.BoxPoints(rect) box = np.int0(box) cv2.drawContours(img,[box],0,(0,0,255),2)

i have written like this but error is coming like TypeError: points is not a numpy array, neither a scalar

( 2016-12-29 00:12:05 -0500 )edit

So, the python have pointed the problem: your "points is not a numpy array, neither a scalar"

( 2016-12-29 01:17:04 -0500 )edit

yeah..i solved this issue.Thank you very much. pnts = np.array(points) rect = cv2.minAreaRect(pnts) box = cv2.cv.BoxPoints(rect) box1 = np.int0(box) cv2.drawContours(resized,[box1],0,(0,255,0),2)

( 2016-12-29 01:26:20 -0500 )edit