Несколько полезных ссылок:
http://urbanar.blogspot.it/2011/04/from-homography-to-opengl-modelview.html
и
http://cvrr.ucsd.edu/publications/2008/MurphyChutorian_Trivedi_CVGPU08.pdf
Когда вы декомпозируете свою P-матрицу в k, R, t, где k - внутренняя матрица, а R, t - относительно поворота и перемещения позы, тогда вы можете сгенерировать соответствующую OpenGL-матрицу следующим образом (мое решение на C ++, но Вы можете понять логику этого):
Eigen::Matrix4d convertIntrinsicToOpenGLProjection(const Eigen::Matrix3d &K,double x0,double y0,double width,double height,double znear,double zfar)
{
double depth = zfar - znear;
double q = -(zfar + znear) / depth;
double qn = -2.0 * (zfar * znear) / depth;
Eigen::Matrix4d proj;
proj << 2*K(0,0)/width, -2*K(0,1)/width, (-2*K(0,2)+width+2*x0)/width, 0 ,
0, -2*K(1,1)/height,(-2*K(1,2)+height+2*y0)/height, 0,
0,0,q,qn,
0,0,-1,0;
return proj;
}
Affine3d convertExtrinsicToOpenGLModelView(const Matrix3d &R, const Vector3d &t)
{
Affine3d MV;
MV.linear().matrix() << R;
MV.translation() << t;
AngleAxis<double> adapter(M_PI,Eigen::Vector3d(1,0,0));
MV = MV*adapter;
return MV.inverse();
}
// Decompose P in k,R,t with any DLT direct linear transform procedure or Zhang method
Eigen::Matrix3d K; //intrinsic calibration matrix
K << 49.30423 , 0.00000 , 387.13187,
0.00000 , 26.81592 , 295.07170,
0.00000 , 0.00000 , 1.00000 ;
int projAreaWidth = 684; //related to the size of your screen
int projAreaHeight = 608;
double x0=0,y0=0;
double zfar=0.1;
double znear=2000;
Matrix4d P = convertIntrinsicToOpenGLProjection( K, x0, y0, width, height, znear, zfar);
Affine3d MV = convertExtrinsicToOpenGLModelView(R, t);
glPushMatrix();
glLoadMatrixd(P.data());
glMultMatrixd(MV.data());
//draw your object
glPopMatrix();
Дайте мне знать, если это имеет смысл для вас.