<p>I am working on an application that detects the most prominent rectangle in an image, then seeks to rotate it so that the bottom left of the rectangle rests at the origin, similar to how IUPR's <a href="http://demo.iupr.org/oscar/oscar.php" rel="noreferrer" title="OSCAR">OSCAR</a> system works.  However, once the most prominent rectangle is detected, I am unsure how to take into account the depth component or z-axis, as the rectangle won't always be "head-on".  Any examples to further my understanding would be greatly appreciated.  Seen below is an example from IUPR's OSCAR system.</p>

<p><a href="http://quito.informatik.uni-kl.de/oscar/oscar.php?serverimage=img_0324.jpg&amp;montage=use" rel="noreferrer" title="Rotation Example">alt text http://quito.informatik.uni-kl.de/oscar/oscar.php?serverimage=img_0324.jpg&amp;montage=use</a></p>

You don't actually need to deal with the 3D information in this case, it's just a mappping function, from one set of coordinates to another.
Look at affine transformations, they're capable of correcting simple skew and perspective effects. You should be able to find code somewhere that will calculate a transform from the 4 points at the corners of your rectangle.
Almost forgot - if "fast" is really important, you could simplify the system to only use simple shear transformations in combination, though that'll have a bad impact on image quality for highly-tilted subjects.