PDA

View Full Version : Obtaining projection Matrix, from Intrinsic Matrix

prash_prash
08-23-2011, 06:58 AM
Hello,

I need help in constructing Projection Matrix from Camera Calibration data.

I have rendered a scene after setting the perspective using gluPerspective() with some values after few trial and errors...and I am able to get a pretty decent rendering.

However I would like to get the 'correct' rendering using the camera calibration file data.

In that file, the Intrinsic Matrix [3x3] is given as:

1914.070000 0.343703 564.645000
0.0 1918.500000 428.422000
0.0 0.0 1.0

Also the Rotation Matrix from the camera is as follows:

0.989230 0.003946 0.146295 -7.784865
-0.004391 0.999983 0.002724 -0.431597
-0.146283 -0.003337 0.989230 1.392058

My question is:
How can I create a projection Matrix [4x4], projMatrx which I can use as an argument to

glMatrixMode(GL_PROJECTION);

I looked at lots of resources for the matrix calculations, but cannot figure out how do I get [4x4] from these values.

I am sure it is a routine thing for the experts out there..please help me out here.

_x57_
08-26-2011, 02:36 AM
How can I create a projection Matrix [4x4], projMatrx which I can use as an argument to

glMatrixMode(GL_PROJECTION);

I am no expert in camera calibration, but the GL_PROJECTION matrix in principle does the projection only and not the camera rotation you described, which is extrinsic and should be rather applied to the modelview matrix.

The intrinsic matrix is a 2d homgeous transformation, so I think it has not much to do with the projection (which is 3d homogenous), but rather with the viewport transformation (look for glViewport, glDepthRange). Setting the viewport will allow you to set the principal point ((564,428) in your case) and a scaling, I think. I am not sure about this, but you might want to try s.th. like

glViewport(564-(1914/2), 428-(1918/2), 1914, 1918)

As for the skew 0.34 ... i am not sure how to integrate this, but i am pretty sure it can't be done in the viewport transform since it is not a freely definable matrix.

Maybe you should use a vertex shader to accomplish the task - this way you might also be able to do nonlinear lens undistort and so on if that is sth you want to do.

BTW: 0.34 for skew - isn't that quite large?

prash_prash
08-29-2011, 05:36 AM
Hello _x57_, thanks a lot for your reply..i will try on your suggested lines and will post what I get, soon...