# Viz: How to Affine Transform a Point3D with R & T vectors? 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 close merge delete

Sort by » oldest newest most voted 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;

more

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

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

@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.

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.

Official site

GitHub

Wiki

Documentation