Let's use the previous MATLAB example to illustrate some principles around homographies. First thing I'm going to do is to close these 2 windows and create a new variable called Little P, which contains the projection of those world points. Here we go.
So, this is the image plane coordinates of the points as viewed by that camera up in the air. The world points P are a set of 3 dimensional coordinates. Note that the Z coordinate of all of these points is equal to 0. So, I'm going to create a new vector, just P and it's just the first 2 rows and it contains all of the columns. So, this is Q. So, Q are a set of coordinates of points on the ground plane that the camera is looking at and P is a set of pixel coordinates in the view from that camera up in the air and now that I have these 2 sets of corresponding 2-D points, I can compute N homography. I'll just use the homography function and I pass in the first set of points, little P and the second set of points, Q and here is the homography matrix that's been computed.
Now that I have the homography H, I can apply it to a single point or to multiple points. To help me with that, there is a toolbox helper function called 'homtrans' which applies the homography H to the set of pixels P. This is our image plane coordinates and the result is the set of coordinates of points on the ground.
We have mapped a set of points in the image whose coordinates are measured in units of pixels into a set of points on the ground plane and there coordinates are described in units of meters. Similarly, I can use the inverse of the homography matrix to go the other way.
So now, I pass in the coordinates of the points and the ground and the result is the set of image plane coordinates. So, the homography is really useful tool if I want to map the coordinates of points between one plane and another.
We use MATLAB and some Toolbox functions to compute an homography and also apply it.
This content assumes an understanding of high school level mathematics; for example, trigonometry, algebra, calculus, physics (optics) and experience with MATLAB command line and programming, for example workspace, variables, arrays, types, functions and classes.