[Math] Find the homography matrix that maps a 2D image point to a 3D world point on a known plane

image processinglinear algebraprojective-geometry

Given a pinhole camera with known 3×4 calibration matrix $P$ how do we find the 3×3 homography matrix $H$ that can map 2D image points to 3D world points given that the 3D points are constrained to a known world plane $\pi$?

Hartley and Zissermann's Multiple View Geometry section 8.1.1 gives a simple case with the world plane $Z=0$.
$$x=PX=\begin{bmatrix}p1 & p2 & p3 & p4\end{bmatrix}
\begin{pmatrix}X \\ Y \\ 0 \\ 1\end{pmatrix}
=\begin{bmatrix}p1 & p2 & p4\end{bmatrix}
\begin{pmatrix}X \\ Y \\ 1\end{pmatrix}
$$
Here the 3×3 homography that maps world points to image points is given by $H=\begin{bmatrix}p1 & p2 & p4\end{bmatrix}$ and the inverse $H^{-1}$ maps homogeneous pixels to world points $$X=H^{-1}x$$
In my case the world points are constrained to a known plane that is parallel to $Z=0$ but offset some known amount $a$. I tried to solve:
$$x=PX=\begin{bmatrix}p1 & p2 & p3 & p4\end{bmatrix}
\begin{pmatrix}X \\ Y \\ a \\ 1\end{pmatrix}$$
But I'm not sure how to proceed in this case because I can't invert the 3×4 matrix on the right. If it exists I'm looking for a solution that gives $H^{-1}$ with parameter $a$ so I don't have to invert a matrix for each point I want to map.

Best Answer

You can just change coordinates so that your parallel plane becomes the plane $Z=0$.

$P\begin{bmatrix}X\\Y\\Z\\1\end{bmatrix}=PA^{-1}\begin{bmatrix}X\\Y\\Z-h\\1\end{bmatrix}$ where $A=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&1&-h\\0&0&0&1\\\end{bmatrix}$.

I think then you can proceed as normal with $PA^{-1}$ by continuing with $Z-h=0$ (i.e. $Z=h$.)

That's the argument that first occurs to me anyway: change world coordinates to make your plane coincide with the $Z$ plane. I have not seen it written down, and I have not applied it, but that seems reasonable.

Related Question