opengl - 3D投影映射

标签 opengl opencv mapping projection projector

我正在尝试使用普通的 LCD 投影仪将图像转换到简单的 3D 形状上,但要以可重复的方式进行。

我需要: 我最简单的例子是,我将一个立方体放在 table 上,将投影仪连接到一定距离的三脚架上,测量两者之间的距离/方向(使用 GOM 摄影产品,http://www.capture3d.com/products-TRITOP.html),打开一个现有的对象(多边形)模型与立方体的形状完全相同(尺寸非常准确),但带有一些“花哨”的颜色,然后将多边形模型投影到 LCD 投影仪。

我做了什么: 花了一个月的时间试图确定我的投影仪的内在/外在常数——相机对、焦距、主点、畸变常数……我想我有它们。 (http://code.google.com/p/procamcalib/)

我找到/修改了打开我的 obj 文件的代码。

我对如何处理投影仪的这些内在/外在常量感到困惑。

我正在使用 opengl/opencv...

最佳答案

一些有用的链接: 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();

如果这对您有意义,请告诉我。

关于opengl - 3D投影映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7181485/

相关文章:

mapping - 使用 spring-data-elasticsearch,如何更新字段映射?

javascript - Node.js Array.map() 是异步的吗?

Delphi - GLScene - 根据图像调整 Sprite 大小

c++ - 在 GPU 上执行计算时 OpenGL 窗口没有响应

c++ - 用cuda计算一张图片,直接用OpenGL显示

c++ - 如何获取圆的半径值

linux - 球体边缘的伪影 - 照明不正确?

c# - 如何获取数组中处于一定范围内的数字数量?

c++ - 使用索贝尔的奇怪方向图。怎么了?

java - 将对象保存到 firebase db 时出现意外错误? (mClassMapper.access$200(com.google.firebase :firebase-database@@16. 0.5:47))