# How do you use OpenCV to find horizontal angle and vertical angle from the center of an image to the center of a rectangular contour?

I need a turret to rotate to a certain point using a camera, so I need angles.

edit retag close merge delete

1

Are you familiar with the dot product operation? https://www.mvps.org/directx/articles...

( 2018-07-05 14:16:02 -0500 )edit

Yes, but I don't know what that has to do with dot product.

( 2018-07-05 14:43:35 -0500 )edit

( 2018-07-05 14:47:55 -0500 )edit

SHAWN!!! HELP!!!

( 2018-07-05 14:48:25 -0500 )edit

It says right on that page how to get the angle from the two vectors. Have fun!

( 2018-07-05 14:51:41 -0500 )edit

HALAYKA WALA BABU!

( 2018-07-05 14:52:17 -0500 )edit

Yes, but what are the vectors?

( 2018-07-05 14:52:47 -0500 )edit

I have 2 points, not vectors!

( 2018-07-05 14:53:02 -0500 )edit

How to get the vectors?

( 2018-07-05 14:55:14 -0500 )edit

It looks like I have to come to Saskatchewan itself to ask you!

( 2018-07-05 14:56:19 -0500 )edit

You subtract the centre point of the rectangle from the centre point of the image to get a vector. You may have to negate it. I'm bad at the math. ;) Your other vector depends on if you're getting the horizontal or vertical angle.

Come live in Saskatchewan, get free healthcare.

( 2018-07-05 15:00:00 -0500 )edit

You should check out a textbook on Linear Algebra.

( 2018-07-05 15:49:55 -0500 )edit

Ok, I'll definitely learn linear algebra soon, but not too soon since I wanna do some OpenCV and make a autonomous turret first.

( 2018-07-05 17:24:32 -0500 )edit