I have some Points and Lines from original image and the corresponding points and lines from top view image.

-> I tried to find homography using points

  1. Used OpenCV function findHomography(objectPointsPlanar, imagePoints) :

    • It takes 4 points from original image and 4 points from top view image(required image) and it returns homography matrix of 3x3.
  2. Used mathematical formula to find homography matrix (Didn't use any library) :

    • Please look at the attached images for the formula to find homography matrix using 4 points by your own. Formula to find homography matrix using 4 points
    • I have tested the formula by writing it in c++. It gives the homography matrix same as given by opencv function findHomography().

PS : I used the determined homography matrix to warp the image, but I am not happy with the output. It doesn't come to be accurate. So I am thinking to use lines to find homography matrix.

-> Homography determination using Lines :

  • I tried to look for any library which can find homography matrix using lines, but I didn't get.
  • I also looked at research papers to get the mathematical formula to find the homography matrix, but was not able to understand the formula.
  • I am sharing the link of a research paper : A new normalized method on line-based homography estimation

So could someone please help me to find the homography matrix using lines.

Thanks in advance, Regards.

  • $\begingroup$ I'm not sure I understand what you're after. $\endgroup$
    – Royi
    Aug 31, 2019 at 6:49
  • $\begingroup$ I want to find homography using lines. How to find homography using lines ? $\endgroup$
    – User4680
    Sep 2, 2019 at 4:58
  • $\begingroup$ Have you developed what is the general closed form transformation for a line? $\endgroup$
    – Royi
    Sep 2, 2019 at 5:05
  • $\begingroup$ Do you mean line equations ? $\endgroup$
    – User4680
    Sep 2, 2019 at 5:11
  • $\begingroup$ I have got the line equations for some 4-5 lines. $\endgroup$
    – User4680
    Sep 2, 2019 at 5:12

1 Answer 1


I am not aware of any library which works directly on lines.

A by pass would be, that given 2 line, you'd use a finites sample of point on the lines to calculate the Homography.

To derive the Homography given lines, the Math goes by:

  1. Consider a line $ \boldsymbol{l} $ which obeys for any point $ \boldsymbol{x} \in \boldsymbol{l} $ that $ \boldsymbol{x}^{T} \boldsymbol{l} = 0 \Leftrightarrow \boldsymbol{l}^{T} \boldsymbol{x} = 0 $. On the same manner consider a line on the other image such that $ \boldsymbol{x}'^{T} \boldsymbol{l}' = 0 \Leftrightarrow \boldsymbol{l}'^{T} \boldsymbol{x}' = 0 $.
  2. Consider an Homography matrix such that $ \boldsymbol{x}' = H \boldsymbol{x} $.
  3. Then we can derive the following:

$$\begin{aligned} \boldsymbol{l}'^{T} \boldsymbol{x}' & = 0 && \text{} \\ & = \boldsymbol{l}'^{T} H \boldsymbol{x} && \text{As $ H \boldsymbol{x} = \boldsymbol{x}'$} \\ & = {\left( {H}^{T} \boldsymbol{l}' \right)}^{T} \boldsymbol{x} && \text{} \\ & = \boldsymbol{l}^{T} \boldsymbol{x} && \text{As $ \boldsymbol{l}^{T} \boldsymbol{x} = 0 $} \\ & = {\left( {H}^{T} \boldsymbol{l}' - \boldsymbol{l} \right)}^{T} \boldsymbol{x} && \text{} \\ & \Rightarrow \boldsymbol{x} \in \ker {\left( {H}^{T} \boldsymbol{l}' - \boldsymbol{l} \right)}^{T} \end{aligned}$$

Which means that for the Homography $ \boldsymbol{l}' = {H}^{T} \boldsymbol{l} $ as required.

  • $\begingroup$ This is incorrect, see e.g. this paper by Dubrofsky for a discussion on how to use lines or points or both: "Combining Line and Point Correspondences for Homography Estimation" $\endgroup$ May 10, 2022 at 17:56
  • $\begingroup$ @nbubis, Does the paper suggest it can be done with lines only or combining lines and points? $\endgroup$
    – Royi
    May 10, 2022 at 18:10
  • $\begingroup$ Read the paper - it explicitly shows how one can use the DLT method to find the homography from 4 lines. $\endgroup$ May 10, 2022 at 19:09
  • $\begingroup$ @nbubis, OK. I hope to get time and read it. It might add information to revise the answer. The answer is still half valid as this paper isn't taught usually when we learn the subject. I, to the least, was taught that for some translations lines won't preserve. I need to see if the paper shows that any line is preserved or only under the assumption it was preserved. Thank You. $\endgroup$
    – Royi
    May 10, 2022 at 19:39
  • $\begingroup$ @nbubis, I updated the answer and derived the correct relationship for lines (Extended what's on the paper). Thanks for the reference. By the way, the answer still stands, as for a library which only supports working on points one has to extract some points from the given lines and work on them. $\endgroup$
    – Royi
    May 20, 2022 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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