mathgraphics3dcomputer-visionogre

Warpping a camera image into 2D Quad without opencv


I'm doing AR application where I have camera pose orientation and position.

Given 4 points in world coordinates, how would I wrap the camera image into 2D quad ?

So given the Right image, I would like to get a 2D quad as shown in the left.


Solution

  • Parameters of perspective transformation matrix could be calculated using system of 8 equations for initial and warped coordinates of points:

    x1' = (A * x1 + B * y1 + C) / (G * x1 + H * y1 + 1.0)
    y1' = (D * x1 + E * y1 + F) / (G * x1 + H * y1 + 1.0)
    

    You can find description of perspective transformation math in in Paul Heckbert article.

    Example of implementation (C++): Antigrain library (file agg_trans_perspective.h)