last day (15 days later) » 

3:21 PM
1
A: Removing data from list inside two for loops

hansaplastTo remove duplicates from a list you basically need to compare every element with every other element from the list. In order to not compare twice you need to start the second loop at the position of the first loop + 1. The following code does that, and if it finds a duplicate skips the first of...

 
Doesn't this only find one line that is close to the other ? What if I have 5 lines which are close by and i want to consolidate all of them ?
 
No, it will check every pair. Let's say you have 4 items 1,2,3,4 then it will compare 1-2, 1-3, 1-4, 2-3, 2-4, 3-4
you may add a print(line1, line2) into the inner for loop to understand what's going on
 
(100, 100, 200, 200); (100, 100, 200, 201); (100, 100, 200, 199); (100, 100, 200, 100); (100, 100, 200, 101); (100, 100, 200, 99.9); (100, 100, 200, 100.1); So I tried with these lines as (x1, y1, x2, y2) values. I expected only 2 outputs. The output is : (100 , 100 , 200 , 199) (100 , 100 , 200 , 100) (100 , 100 , 200 , 99.9) The last two should have been consolidated
 
@navderm what's the value of SomeValue and someOtherValue? Then I could try to reproduce
also: in your question you said you want to compare the values of the functions m() and c(), but now you're posting only x1,x2,y1,y2. I'm confused
@navderm were you able to get it working?
 
@hansaplast: Hey. Nope. So the input is (x1, y1, x2, y2). Internally the values of m, c, length are updated at construction. The output is (x1, y1, x2, y2) because that's how it'll be drawn. (x1, y1, x2, y2, m, c, length ) are persisted within the line data structure.
@hansaplast: The values of threshold for m comparison as represented by math.degrees(m2 - m1) is 5 and for (c2 - c1) is 50.
 
3:21 PM
@navderm if you'd like you can post the relevant code to gist.github.com and I'll have a look on what the problem could be
 
@hansaplast : Take a look at consolidateLines2(). Not consolidateLines()
 
@navderm I moved out into a chat, as stackoverflow suggested
I'll look into it in around 4 hours
thanks for the gist, btw, that should be enough to reproduce the issue you're facing
 
alright cool.
 
3:42 PM
Do you have experience with hough llines in opencv ?
 
4:22 PM
no, haven't used opencv yet
smells like a new question for stackoverflow :-)
hopefully you're experience on SO was good so far
sometimes it's a bit a rough place
 
5:01 PM
yeah there are people who have posted that question. I am trying to modify those with this piece to get better detection.
Yeah SO gets me good answers!
 
 
3 hours later…
8:06 PM
I ran your script (after adding printing of DSLine).

What's the error in the following consolidateLines2():

$ python script.py
before
x1=100, y1=100, x2=200, y2=200. c=0, m=1
x1=100, y1=100, x2=200, y2=201. c=0, m=1
x1=100, y1=100, x2=200, y2=199. c=100, m=0
x1=100, y1=100, x2=200, y2=100. c=-57.0796326795, m=1.57079632679
x1=100, y1=100, x2=200, y2=101. c=100, m=0
x1=100, y1=100, x2=200, y2=99.9. c=100.1, m=-0.001
after
x1=100, y1=100, x2=200, y2=201. c=0, m=1
x1=100, y1=100, x2=200, y2=100. c=-57.0796326795, m=1.57079632679
after the method there are only 3 lines left
with max_distance_c = 500 and max_distance_m = .5 that looks correct, no?
 

  last day (15 days later) »