Ask Your Question
0

Viz: How to Affine Transform a Point3D with R & T vectors?

asked 2017-04-19 23:24:00 -0500

Balaji R gravatar image

updated 2017-04-19 23:25:11 -0500

I'm trying to simulate the movement of camera in 3D using OpenCV Viz module. I want to find the Location of a Camera in 3D in the world coordinates! I specify the pose of the camera like this!

How can I get the Location of the camera from the pose "Affine3d "? Note that the Origin is located at Point3d(0,0,0). Do I need to compute this manually? If yes How to transform the Point?

    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;
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-04-20 04:42:33 -0500

Balaji R gravatar image

updated 2017-04-20 04:43:01 -0500

Just Figured it out! You can directly multiply with the Point3d to transform the point like this.

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;
edit flag offensive delete link more

Comments

Did you manage the movement of camera in 3D using OpenCV Viz?

LBerger gravatar imageLBerger ( 2017-05-26 14:14:08 -0500 )edit

@LBerger Yes! Please refer the following sample https://pastebin.com/h7TwCi5x

Balaji R gravatar imageBalaji R ( 2017-05-27 07:19:04 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-04-19 23:24:00 -0500

Seen: 37 times

Last updated: Apr 20