简体   繁体   中英

How to find intersection points between a line and polyfit in opencv?

I am currently working on lane detection on opencv. I detected right and left line pixel coordinates for lane in seperate parameters such as:

  • left_line_x (= contains pixel x coordinates that belongs left line)
  • left_line_y

  • right_line_x

  • right_line_y

And then created 2 polyfits with them which are;

left_line = np.polyfit(left_line_y, left_line_x, 2)

and same for right.

Because there are many pixel points that I've detected (59168 for only left for example) I want to draw imaginary horizontal lines to the image and then look for intersection points between those lines and line polyfits (left_line).

How can I do this? Especially need help on the intersection part. Thanks in advance.

2 degrees of freedom does not match the inputs given in the original problem. I've assumed 1 degree of freedom for the solution below.

To find the intersection of lines given the output from numpy.polyfit(), try the following:

x0 = -(left_line[1] - right_line[1])/(left_line[0]-right_line[0])
y0 = x0*left_line[0] + left_line[1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM