tincan
tincan

Reputation: 187

How to find end points of a line in opencv?

I am trying to figure out how to find the end points of a line. Lets say that I have a line that goes from (0,0) to (2,2) in a cartesian coordinate system and opencv sees the line using Probabilistic Hough Line Transform, how do I find those 2 points?

I know that hough line transform finds lines by matching up points, but how do I use that line and find the two points that make up that line?

Are there any functions that are already built into the library that provides this functionality?

I'm using OpenCV 2.4.3 in C++ in

VS Studio 2010

Thanks for the help.

Upvotes: 0

Views: 3209

Answers (1)

ArtemStorozhuk
ArtemStorozhuk

Reputation: 8725

What about using HoughLinesP:

lines – Output vector of lines. Each line is represented by a 4-element vector (x1,y1,x2,y2), where (x1,y1) and (x2,y2) are the ending points of each detected line segment.

There's even example of usage.

Upvotes: 1

Related Questions