Please see this page for the most up to date information regarding this post and code.
A few months ago I wrote an OpenCV version of the pose estimation algorithm found in the paper Robust Pose Estimation from a Planar Target (2006) by Gerald Schweighofer and Axel Pinz using their Matlab code from the link in the paper.
I originally ported it so I could play around with Augmented Reality, specifically to track a planar maker (business card). Although that project hasn’t received much attention lately I figured someone might find the pose estimation part useful. I was about to post it up last night when I came across a small bug, which took 2-3 hour to hunt down. Seems like the new OpenCV Mat class has some subtle gotchas but all good now.I checked my results with the original Matlab code and they appear numerically the same, which is always a good sign.
Download RobustPlanarPose-1.1.2.zip
Look at demo.cpp to see how it works.
UPDATE: 12 March 2012
If you plan to use this for Augmented Reality applications then you should modify Line 23 in RPP.cpp from:
ObjPose(model_3D, iprts, NULL, &Rlu, &tlu, &it1, &obj_err1, &img_err1);
to
ObjPose(model_3D, iprts, &Rlu, &Rlu, &tlu, &it1, &obj_err1, &img_err1);
This initialise the guess of the rotation matrix to the last estimate, providing smoother and more accurate results.