This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

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 ?

2 | No.2 Revision |

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)~~a.y) / float(b.x -~~a-x);~~a.x);the length is the euclidean distance, or:

norm(a,b);

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

3 | No.3 Revision |

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 ?

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.