Ask Your Question
0

Calculate x distance to line from edge at middle of y?

asked 2017-06-24 14:33:45 -0600

Hi.

So right now I'm using HoughLines to find the distance to a line and the angle of the line. My problem is though that HoughLines calculates the distance to the line (rho) from the origin normal to the line which depends on the angle of the line as can be seen here (http://answers.opencv.org/question/29...).

I want to find the distance to the line in pixels at the middle of the frame and the angle of the line as this rough sketch shows: http://i.imgur.com/mNePsR7.png.

Any tips on how to do this? I would guess using HoughLinesP with the different output from HoughLines and doing some calculations would work, anyone done this before?

There is always only one line in the image and it is always longer than the camera frame.

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-24 19:41:43 -0600

Tetragramm gravatar image

Well, this is more geometry than computer vision, but here you go.

Turn your line into the form y = m*x+b. If you don't know how, use the example to get two points on the line, and solve. Then x = (y-b)/m, where y = rows/2

edit flag offensive delete link more

Comments

This representation is numerically unstable and not able to handle vertical lines.

FooBar gravatar imageFooBar ( 2017-06-25 06:11:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-06-24 14:33:45 -0600

Seen: 265 times

Last updated: Jun 24 '17