# Revision history [back]

### Can I use cv::fitLine() to robustly find an intersection point?

cv::fitLine provide robust line fitting algorithms, that ought to be better than the regular least-square fitting.
I am wondering if cv::fitLine can be "abused" to robustly find the "best" intersection point of a large number of image lines.

I can just list each image line as a 3D (homogrphic) point and then call cv::fitLine. The result after normalizing should be the best fitting point.

Is there any reason this will not work? After all lines and point are duals in 2D space, and identical in 2D projective space.

### Can I use cv::fitLine() to robustly find an intersection point?

cv::fitLine provide robust line fitting algorithms, that ought to be better than the regular least-square fitting.
I am wondering if cv::fitLine can be "abused" to robustly find the "best" intersection point of a large number of image lines.

I can just list each image line as a 3D (homogrphic) point and then call cv::fitLine. The result after normalizing should be the best fitting point.

Is there any reason this will not work? After all lines and point are duals in 2D space, and identical in 2D projective space.

If it does work, then what should the param, reps and aeps parameters be?

### Can I use cv::fitLine() to robustly find an intersection point?

cv::fitLine provide robust line fitting algorithms, that ought to be better than the regular least-square fitting.
I am wondering if cv::fitLine can be "abused" to robustly find the "best" intersection point of a large number of image lines.

I can just list each image line as a 3D (homogrphic) point and then call cv::fitLine. The result after normalizing should be the best fitting point.

Is there any reason this will not work? After all lines and point are duals in 2D space, and identical in 2D projective space.

If it does work, then what should the param, reps and aeps parameters be?

### Can I use cv::fitLine() to robustly find an intersection point?

cv::fitLine provide robust line fitting algorithms, that ought to be better than the regular least-square fitting.
I am wondering if cv::fitLine can be "abused" to robustly find the "best" intersection point of a large number of image lines.

I can just list each image line as a 3D (homogrphic) point and then call cv::fitLine. The result after normalizing should be the best fitting point.

Is there any reason this will not work? After all lines and point are duals in 2D space, and identical in 2D projective space.

If it does work, then what should the param, reps and aeps parameters be?

UPDATE:

I tried what I described above. I used the 2D lines as 3D point (an Nx3 matrix) and got back a 6-element vector [P,D]. I used this to create 3D points, P and Q=P+D, which I then normalized by the 3rd coordinate to get 2 2D homographic points. I found the parametric line L through P and Q, and after normalizing L by its 3rd coordinate I got the desired intersection point.

A few notes:

1. Using CV_DIST_L2 with cv::fitLine does not give exactly the same results as using the SVD solver to find the least-square null-space of the matrix.
In fact, in certain cases I got #INF where the SVD worked without a problem.
2. I did not see a lot of differences between the different M-estimator methods, except when sometimes some would give a completely wrong result.

### Can I use cv::fitLine() to robustly find an intersection point?

cv::fitLine provide robust line fitting algorithms, that ought to be better than the regular least-square fitting.
I am wondering if cv::fitLine can be "abused" to robustly find the "best" intersection point of a large number of image lines.

I can just list each image line as a 3D (homogrphic) point and then call cv::fitLine. The result after normalizing should be the best fitting point.

Is there any reason this will not work? After all lines and point are duals in 2D space, and identical in 2D projective space.

If it does work, then what should the param, reps and aeps parameters be?

UPDATE:

I tried what I described above. I used the 2D lines as 3D point (an Nx3 matrix) and got back a 6-element vector [P,D]. I used this to create 3D points, P and Q=P+D, which I then normalized by the 3rd coordinate to get 2 2D homographic points. I found the parametric line L through P and Q, and after normalizing L by its 3rd coordinate I got the desired intersection point.

A few notes:

1. Using CV_DIST_L2 with cv::fitLine does not give exactly the same results as using the SVD solver to find the least-square null-space of the matrix.
In fact, in certain cases I got #INF where the SVD worked without a problem.
2. I did not see a lot of differences between the different M-estimator methods, except when sometimes some would give a completely wrong result.