Ask Your Question
0

How to calculate slope, length and distance between hough lines?

asked 2017-05-08 06:12:42 -0600

Lavanya gravatar image

To detect lines from my image I used problabistic hough transform. I got 15 lines from my image. now I want to calculate slope, length of each line and to calculate distance between nearest lines? Can anyone suggest me ideas or share code? Thanks in advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-05-08 06:31:19 -0600

berak gravatar image

updated 2017-05-08 06:33:04 -0600

really, this is not so much an opencv problem, but a maths one ..

houghlinesP already gives you the endpoints of the line,

Vec4i line = lines[i];
Point a(line[0], line[1]);
Point b(line[2], line[3]);

so

  • the slope is dy/dx , or

    float(b.y - a.y) / float(b.x - a.x);

  • the length is the euclidean distance, or:

    norm(a,b);

no idea, what you mean with the distance, try to explain ?

edit flag offensive delete link more

Comments

may be this

LBerger gravatar imageLBerger ( 2017-05-08 07:28:33 -0600 )edit

In my image I got two parallel lines. Now I calculated slope and length of each line respectively. I want to calculate distance between these two parallel lines.

Lavanya gravatar imageLavanya ( 2017-05-08 07:46:12 -0600 )edit

the distance is somewhat tricky. the link, @LBerger sent, assumes infinite lines, this probably won't work here.

by best guess, atm: take the shortest of the 4 point distances: a1,a2 a1,b2 b1,a2 b1,b2

berak gravatar imageberak ( 2017-05-09 03:33:44 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-05-08 06:12:42 -0600

Seen: 5,777 times

Last updated: May 08 '17