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?

asked 2018-07-05 12:04:08 -0500

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

edit retag flag offensive close merge delete

Comments

1

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

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

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

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

PLEASE HELP SHAWN!

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

SHAWN!!! HELP!!!

OpenCVNoob69 gravatar imageOpenCVNoob69 ( 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!

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

HALAYKA WALA BABU!

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

Yes, but what are the vectors?

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

I have 2 points, not vectors!

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

How to get the vectors?

OpenCVNoob69 gravatar imageOpenCVNoob69 ( 2018-07-05 14:55:14 -0500 )edit

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

OpenCVNoob69 gravatar imageOpenCVNoob69 ( 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.

sjhalayka gravatar imagesjhalayka ( 2018-07-05 15:00:00 -0500 )edit

You should check out a textbook on Linear Algebra.

sjhalayka gravatar imagesjhalayka ( 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.

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