Ask Your Question
0

How to find angle between two line?

asked 2014-10-02 00:40:45 -0600

xyzautomation gravatar image

updated 2014-10-02 02:35:15 -0600

Please tell me how to find angle between two lines using OpenCV?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2014-10-02 03:44:50 -0600

rwong gravatar image

The answer depends on how you represent the line objects.

As you may have found out yourself, OpenCV does not come with a standard representation for 2D lines, whether it is finite (line segment), semi-finite (ray), or infinite (line equation).

Due to historical reasons, each algorithm that uses line objects adopt whatever was more convenient, or rather more "historical", representation.

Most of the time, when the finite line segment representation is used, the point pair (two cv::Point_<T> objects) are used to denote the two endpoints.

In some other usage, the line equation a * x + b * y + c == 0 would be far more convenient; unfortunately OpenCV does not provide native support for it.

To answer your question, when the point-pair representation is used, the cosine formula can be used.

http://mathworld.wolfram.com/Line-LineAngle.html

As an unrelated but useful note, you can find a lot of mathematically relevant answers on the Wolfram MathWorld website. It only requires high-school geometry and calculus to be able to search for answers there.

edit flag offensive delete link more
1

answered 2014-10-02 02:46:42 -0600

You can start by making sure that the next time, you do not add 100 question marks just to make your point clear. As to the solution of your problem, using the search function would have given you the following result:

  1. http://www.pdnotebook.com/2012/07/measuring-angles-in-opencv/
  2. http://feelmare.blogspot.be/2012/10/inner-productthe-angle-between-two.html

However this isn't really a OpenCV problem, rather a mathematical problem.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-10-02 00:40:45 -0600

Seen: 18,835 times

Last updated: Oct 02 '14