After looking at this again, I am unclear as to whether you have built
the projection matrix from the intrinsic parameters. I was assuming that
you had made it by hand. To do that you would do something like this:
//-----------------------------------------------------------------------------//
// The _intrinsic variable holds the five values for the intrinsic
// matrix. The intrinsic * our pixel transform to get the projections
// matrix. The intrinsic values (itr[]) are given as five doubles
// such that:
//
// | itr[0] itr[1] itr[2] |
// | 0 itr[3] itr[4] |
// | 0 0 0 |
//
// | alpha_u gamma u_0 |
// | 0 alpha_v v_0 |
// | 0 0 0 |
//
//-----------------------------------------------------------------------------//
void
-Camera::calcProjection() {
double alpha_u, alpha_v;
// calc alphas
alpha_u = _intrinsic[0];
double cot_theta = - _intrinsic[1]/_intrinsic[0];
double sin_theta = sqrt(1/(1+cot_theta*cot_theta));
alpha_v = _intrinsic[3] * sin_theta;
double skew = _intrinsic[1];
double u0, v0;
u0 = _intrinsic[2]; v0 = _intrinsic[4];
double left = -u0 / alpha_u * _near;
double bottom = (_screen_height-v0) / alpha_v * _near;
double right = (_screen_width - u0) / alpha_u * _near;
double top = -v0 / alpha_v * _near;
_projection[0] = 2 * _near / (right - left);
_projection[4] = 2 * _near * skew / ((right - left) * alpha_u);
_projection[5] = 2 * _near / (top - bottom);
_projection[8] = -(right + left)/(right - left);
_projection[9] = -(top + bottom)/(top - bottom);
_projection[10] = (_far + _near) / (_far - _near);
_projection[11] = 1;
_projection[14] = -2 * _far * _near/(_far-_near);
|}
On Tue, 27 Jul 2010, Ricky Flintoff wrote:
Hi,
I have a quick question. I looked up online on setting camera intrinsics (5
parameters, including radial distortion). Would I be using
viewer.getCamera()->setProjectionMatrixAsPerspective(intrinsic_parameter_matrix)?
Also, can I do this (with a different matrix) before rendering each frame?
Thank you!
Cheers,
Ricky
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30318#30318
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org