Ask Your Question
0

how to find angle from x y points?

asked 2016-12-28 07:32:11 -0500

Rashmi gravatar image

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-12-28 08:02:18 -0500

pi-null-mezon gravatar image

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

edit flag offensive delete link more

Comments

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

Rashmi gravatar imageRashmi ( 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

Rashmi gravatar imageRashmi ( 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"

pi-null-mezon gravatar imagepi-null-mezon ( 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)

Rashmi gravatar imageRashmi ( 2016-12-29 01:26:20 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-12-28 07:32:11 -0500

Seen: 588 times

Last updated: Dec 28 '16