Ask Your Question
0

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

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

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

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 -0600

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

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 -0600 )edit

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

Balaji R gravatar imageBalaji R ( 2017-05-27 07:19:04 -0600 )edit

Thanks now may be you can help me to solve this problem using sfm and viz

LBerger gravatar imageLBerger ( 2017-05-28 08:23:17 -0600 )edit

@LBerger I can't quite understand your problem! You already have the pose of the Camera (vector<Affine3d> path;) If you want a point3d you multiply that with Origin. What exactly you want? Also, note that that is not your actual camera pose! You are viewing from world space, Switch to Camera View (from my example) to render the actual scene from the camera.

Balaji R gravatar imageBalaji R ( 2017-05-28 09:02:19 -0600 )edit

In issue image I think pose is wrong. I have got box images with 6 faces. I haven't got an image with this face. Now instead of define pose as Affine3d(Rs_est[i],ts_est[i]) I use Affine3d(Rs_est[i],ts_est[i]).inv() I can see good pose and good trajectory in viz window. Pose is given by sfm module.

LBerger gravatar imageLBerger ( 2017-05-28 09:10:10 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 2,525 times

Last updated: Apr 20 '17