Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

I know you can calculate homographies from image to camera plane using correspondence points between a "perfect model" and the image points.

I'm doing it for a football pitch/field, and have used edge detection to find the white lines in the pitch.

But the camera does not (always) cover all of the pitch, so I can't see all the corners... and I only the corners are 100% known points in the model (no other distinguished points).

So the problem is that unless the line intersects with another line and forms a corner, I only know the image points of the line, not it's corresponding "perfect/real-world" coordinates in the model.

Is there some way I can use the detected lines to calculate a homography, or even just a set of candidate homographies, even if the detected lines do not intersect with each other and create a corner?

Example image, showing the pitch, our field of view, and the points of the pitch where I can know the corresponding realworld/model coordinates(green circles), and an example of 2 lines that might be completely useless since in our field of view, I have no clue exactly at which point they start or stop in the corresponding realworld /model of the pitch:

enter image description here The red lines are examples of lines which I would like to use, but I don't know their realworld coordinates, and it's kind of hard to estimate them because depending on the camera pose, the correspondent points could be "anywhere".

share|improve this question
Do you have some example images? Or at least a sketch of possible cases for line detection? I think the short answer to your question is "yes, you can", but more details from you would help to give more detailed answer :) –  penelope Nov 28 '12 at 9:32
Can you provide an example image? Are you saying that the detected line segments don't intersect or have you tried extending the detected segments to lines and then tried finding intersections? –  ppalasek Nov 28 '12 at 9:33
I added an example image to the question –  Henrik Kjus Alstad Nov 28 '12 at 11:35

2 Answers 2

One approach would require a line matching algorithm. After matching the lines, you could simply use the end points of the lines in order to compute homography. To achieve that EDLine or LSD based descriptors are recently proposed in OpenCV. Also, hashing and fast matching of them are also implemented. Check out the videos here:

http://www.youtube.com/watch?v=MqMjvSkM39k http://www.youtube.com/watch?v=naSWTlbg3To

The recent opencv_contrib repository contains the source code to these methods.

In the case that the line end points are noisy, you could then directly utilize the lines to compute the homographies. Such papers would then read:

Internal Report: 2005-V04 Computing Homographies from Three Lines or Points in an Image Pair G. Lopez-Nicolas, J.J. Guerrero, O.A. Pellejero, C. Sagues

Internal Report: 2003-V01 Robust line matching and estimate of homographies simultaneously G. Lopez-Nicolas

Probabilistic Matching of Lines for Their Homography Taemin Kim, Jihwan Woo, and In So Kweon

share|improve this answer

If the lines are not parallel, you can calculate the point of their intersection and use it as a point of reference. In your painting, you can use the purple points as well:

enter image description here

By the way, the intersection of the lines need not to be in the image. As long as the lines are parallel

If the lines are parallel, you can use them to get additional constraints. For instance if you have N<4 points and K lines you might be able to estimate the transformation

Recall that the equation of projective transformation is:

$x' = \frac{\left ( a_{11}x+a_{12}y+a_{13} \right ) } {\left ( a_{31}x+a_{32}y+1 \right )} \\ y' = \frac{\left ( a_{21}x+a_{22}y+a_{23} \right ) } {\left ( a_{31}x+a_{32}y+1 \right )} $

Your goal is to find the coefficients $a_{11},a_{12},a_{13},a_{21},a_{22},a_{23},a_{31},a_{32} \\$

Thus, if there is a line $ax+by+c=0$ that maps to $Ax'+By'+C$, then:

$ Ax'+By'+C = 0 \implies \\ A(a_{21}x+a_{22}y+a_{23}) + B(a_{21}x+a_{22}y+a_{23}) + C( a_{31}x+a_{32}y+1) = 0 $

It can be re-written as :

$ \left( \begin{array}{ccc} Ax & Ay & A & Bx & By & B & Cx & Cy \\ \end{array} \right) \left( \begin{array}{ccc} a_{11} \\ a_{12} \\ a_{13} \\ a_{21} \\ a_{22} \\ a_{23} \\ a_{31} \\ a_{32} \\ \end{array} \right) = -C $

$A,B,C$ are known values, because you calculated the lines equations. You can input any point $(x,y)$ for which $ ax+by+c = 0 $, and get additional constraint. Combine them together with the constraints that you get from points, and you might get additional information. Note that you will not get more information from more than two points, since any third point will add linear dependent lines to the matrix of constraints.

Additional references "Homography estimation by Elan Dubrovsky" - See part 2.3.1, estimation of homography from lines.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.