Ask Your Question
1

lines parallel with houghlines opencv+python

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

GUI gravatar image

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 flag offensive close merge delete

Comments

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

noiro gravatar imagenoiro ( 2016-12-15 15:09:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-01-13 11:03:51 -0500

Haris gravatar image

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.

edit flag offensive delete link 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)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-01-14 02:45:39 -0500 )edit

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

GUI gravatar imageGUI ( 2015-01-14 14:37:14 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 2,107 times

Last updated: Jan 13 '15