[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 itr itr  |
> //    |   0    itr itr  |
> //    |   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;
> double cot_theta = - _intrinsic/_intrinsic;
> double sin_theta = sqrt(1/(1+cot_theta*cot_theta));
> alpha_v = _intrinsic * sin_theta;
>
> double skew = _intrinsic;
>
> double u0, v0;
> u0 = _intrinsic; v0 = _intrinsic;
>
> 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 = 2 * _near / (right - left);
> _projection = 2 * _near * skew / ((right - left) * alpha_u);
> _projection = 2 * _near / (top - bottom);
> _projection = -(right + left)/(right - left);
> _projection = -(top + bottom)/(top - bottom);
> _projection = (_far + _near) / (_far - _near);
> _projection = 1;
> _projection = -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, _projection, _projection and _projection have opposite signs.

I'm also a bit surprised that the projection matrix generated by OSG (makePerspective) has -1 instead of 1 for _projection. 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