[osg-users] Camera intrinsics
benedikt naessens
benedikt.naessens at spaceapplications.com
Wed Apr 6 04:36:40 PDT 2011
Keith Parkins wrote:
> 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);
>
> |}
>
>
> /lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
------------------
Post generated by Mail2Forum[/quote]
There seems to be a mismatch between the projection matrix generated by e.g. makePerspective and the projection matrix elements you suggest here.
When I do the comparison between the two, it seems that:
_projection[5], _projection[8], _projection[9] and _projection[11] have opposite signs.
I'm also a bit surprised that the projection matrix generated by OSG (makePerspective) has -1 instead of 1 for _projection[11]. Maybe that has something to do with the inversion of the Y axis (0,0 in the bottom left instead of the top left) ?
Can you give me a suggestion why these differences exist ?
Thanks !
Benedikt.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38253#38253
More information about the osg-users
mailing list