3

I'm trying to use a common LCD projector to shine an image onto a simple 3D shape, but do it in a repeatable way.

What I need: My simplest example is, I place a cube on a table, place a projector attached to a tripod some distance away, measure the distance/orientation between the two (using GOM photogammetry product, http://www.capture3d.com/products-TRITOP.html ), open an existing obj (polygon) model that is exactly the same shape as the cube (dimensionally very accurate), but with some 'fancy' coloring, then project the polygon model to the LCD projector.

What I've done: Spent a month trying to determine the intrinsic / extrinsic constants of my projector - camera pair, focal length, principle point, distortion constants... and I think I have them. (http://code.google.com/p/procamcalib/)

I've found/modified code to open my obj file.

I'm stuck with what to do with these intrinsic/extrinsic constants for the projector.

I'm using opengl / opencv...

4

2 回答 2

1

一些有用的链接: http ://urbanar.blogspot.it/2011/04/from-homography-to-opengl-modelview.html

http://cvrr.ucsd.edu/publications/2008/MurphyChutorian_Trivedi_CVGPU08.pdf

首先,当您在 k,R,t 中分解 P 矩阵时,其中 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();

让我知道这对你是否有意义。

于 2013-04-15T11:06:28.783 回答
0

您可以按照此处所述从焦距计算相机的视野。一旦有了视野,就可以使用 gluPerspective() (或自己进行计算- 请参阅第 9.085 节)来设置透视矩阵。您显然还需要根据投影仪和对象的位置来更改模型视图矩阵。我不知道你有什么失真数据,但你大概也需要考虑到这一点。

于 2012-01-02T17:10:53.133 回答