2017-04-20 27 views
0

我试图用OpenCV Viz模块来模拟3D摄像机的运动。我想在世界坐标中找到三维相机的位置!我指定这样的相机的姿势!Viz:如何仿射用R&T矢量变换Point3D?

如何从姿势“Affine3d”中获取相机的位置?请注意,Origin位于Point3d(0,0,0)。我是否需要手动计算?如果是的话如何转换点?

Mat RotationVector(1,3,CV_64FC1,Scalar(0.0)); 
    Mat TranslationVector(3,1,CV_64FC1,Scalar(1.0)); 
    Affine3d AffineTransform= Affine3d(RotationVector,TranslationVector); 

    cout << "RotationVector: \n"  << RotationVector <<endl; 
    cout << "TranslationVector: \n " << TranslationVector <<endl; 
    cout << "AffineTransform: \n"  << AffineTransform.matrix <<endl; 

回答

0

只是想出来了!你可以直接乘以Point3d来转换点。

Point3d Pt3D_Camera(0.0,0.0,0.0), 
      Pt3D_Origin(0.0,0.0,0.0); 
Mat RotationVector(1,3,CV_64FC1,Scalar(0.0)); 
Mat TranslationVector(3,1,CV_64FC1,Scalar(1.0)); 
Affine3d AffineTransform= Affine3d(RotationVector,TranslationVector); 

Pt3D_Camera= AffineTransform* Pt3D_Origin; 

cout << "RotationVector: \n"  << RotationVector <<endl; 
cout << "TranslationVector: \n " << TranslationVector <<endl; 
cout << "AffineTransform: \n"  << AffineTransform.matrix <<endl;   
cout << "Pt3D_Camera: \n"   << Pt3D_Camera <<endl;