Warping points based on two corresponding sets of four corners, based on Projective Mappings for Image Warping by Paul Heckbert.
I had first tried a version that pre-solves the system of equations. It seems to work but the unreduced arithmetic from inverting an 8x8 matrix is… long.