Best for crossing several lines.

I am trying to solve the following problem:

  • I analyze the image, and from this analysis I get a set of segments
  • I want to know the intersection of these lines (best suited)

I use the opencv function cvSolve for this . For a reasonable input, everything works fine.

The problem that arises with me is that when I have only one bad segment as the input result, the result is different than expected.

Bad lines influencing result

Details:

  • The upper left image shows the "lonely" purple lines affecting the result (all lines are used as input).

  • The top right image shows how a single violet line (one removed) can influence the result.

  • The bottom left image shows what we want - the intersection of the lines as expected (both purple lines are eliminated).

  • The lower right image shows how the other purple line (the other is removed) can affect the result.

As you can see only two lines, and the result is completely different than expected. Any ideas on how to avoid this are appreciated.

Thank,

Julian

+5
source share
3 answers

The algorithm you use finds, as described in the link, the smallest square solution to the problem. This means that if there are more intersection points, the result will be the average (for a reasonable definition of the average) of real solutions.

: , , , , . , .

+6

RANSAC (, ), , , , " ". , , , , .

+1

, SVD incase line1 = (x1, y1) - (x2, y2); line2 = (x2, y2) - (x3, y3)

Ax = b ;

A = [-(y2-y1) (x2-x1);
     -(y3-y2) (x3-x2);
    .................
    .................] -->(nx2)
x = transpose[s t]     -->(2x1)
b = [-(y2-y1)x1 + (x2-x1)y1 ;
     -(y3-y2)x2 + (x3-x2)y2 ;
    ........................
    ........................] --> (nx1)

Example; Matlab Code

line1=[0,10;5,10]
line2=[10,0;10,5]
line3=[0,0;5,5]

A=[-(line1(2,2)-line1(1,2)),(line1(2,1)-line1(1,1));
-(line2(2,2)-line2(1,2)),(line2(2,1)-line2(1,1));
-(line3(2,2)-line3(1,2)),(line3(2,1)-line3(1,1))];


b=[(line1(1,1)*A(1,1))+ (line1(1,2)*A(1,2));
   (line2(1,1)*A(2,1))+ (line2(1,2)*A(2,2));
   (line3(1,1)*A(3,1))+ (line3(1,2)*A(3,2))];

[U D V] = svd(A)
bprime = U'*b

y=[bprime(1)/D(1,1);bprime(2)/D(2,2)]

x=V*y
0

All Articles