Ask Your Question

# lines parallel with houghlines opencv+python

I need to know how draw lines parallel, I'm beginning with Opencv, please help. I use the houghlines function for detect lines, now I want detect lines parallel, I know that the ecuacion of a lines is y = k*x+b and two lines are parallel when k1 = k2. but how represent this in opencv with houghlines?

edit retag close merge delete

## Comments

Hi,you have found the answer to this question? if you find an answer you can share?

## 1 answer

Sort by » oldest newest most voted In another way,

• Find the angle for each line using the equation

 double Angle = atan2(y2 - y1, x2 - x1) * 180.0 / CV_PI;

• Compare angles for all detected lines to separate parallel lines.

more

## Comments

2

The comparison can be done by applying a K-means clustering on the resulting angles. As to the angles itself, x and y are two points on the line itself (for clarification)

if I use houghlinesP I can calculate m = (y2 - y1) / (x2 - x1) but I don't know how to compare between each item or pair of points (x1y1 and x2y2) of lines vector []. I trying with itertools.combination but I don't know how to do

Official site

GitHub

Wiki

Documentation

## Stats

Asked: 2015-01-13 10:49:59 -0500

Seen: 2,107 times

Last updated: Jan 13 '15