Ask Your Question
0

Generation of a Transformation Matrix

asked 2013-06-05 03:57:47 -0500

Waterplanto gravatar image

updated 2013-06-05 04:00:26 -0500

Hi :) I need your help. I want to generate a 4x4 Transformation Matrix out of the StereoCalibration Process. So the Stereo/Rectification Process returns a 3x3 Rotation Matrix R and a 3x1 Translation Matrix T. How can I now transform a Point of Cam#1 to the coordinate system of Cam#2. I tried several things - but nothing worked for me. For example - following 4x4 Matrix:

R R R T

R R R T

R R R T

0 0 0 1

And multiplicated a 3D Points of Cam1 with the Matrix.

Again - I want to transform a 3D Point of Cam#1 (e.g. 1|0|0) to the coordinate System of the second Matrix. I hope you can help me :)

Thank you very much!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-06-05 04:49:44 -0500

berak gravatar image

in general, you multiply a Mat by a row-vector, and receive a transformed col-vector.

vc = M * vr;

you could setup your Mat in the usual way, Mat m(4,4,CV32F); and assign one element after the other, but in this case you might want to profit from the ease of Mat_:


Mat m = (Mat_<float>(4,4) << 1,0,0,3,
                             0,1,0,3,
                             0,0,1,3,
                             0,0,0,1 );

// opencv can only multiply Mat's, so make one for the input vec (1,2,3):
Mat v = (Mat_<float>(4,1) << 1,2,3,1);  // note: 1 as last element
Mat r = m*v;
cerr << r << endl;

[4; 5; 6; 1]

edit flag offensive delete link more

Comments

Oh ok - thank you very much. But the multiplication was not the problem. But I think I know now a possible Problem.

How does OpenCV choose the coordinate system? z is for sure in the direction into the scene. But in which directions the x- and y-axis are looking?

Thank you very much :)

Waterplanto gravatar imageWaterplanto ( 2013-06-06 01:29:27 -0500 )edit

And where is the origin of the transfromation? It is in the center of the image?

Waterplanto gravatar imageWaterplanto ( 2013-06-06 01:37:17 -0500 )edit
  • "right hand" system, z points out of the scene, x right, y up.
  • a transformationmatrix does not have an origin, but the input or output coord-system have one, since x ynd y are derived from the image, that would be top-left, not center
berak gravatar imageberak ( 2013-06-06 02:25:15 -0500 )edit

Ok thank you very much. I will play a bit when I am @home. I will cry if I need help :D

Waterplanto gravatar imageWaterplanto ( 2013-06-06 02:55:12 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-06-05 03:57:47 -0500

Seen: 1,359 times

Last updated: Jun 05 '13