The Khronos Group - a non-profit industry consortium to develop, publish and promote open standard, royalty-free media authoring and acceleration standards for desktop and handheld devices, combined with conformance qualification programs for platform and device interoperability.

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Obj-coordinates to pixel-coordinates: wich steps?

Suppose that i have a transformation matrix R, a vector T and that i use R and T to model the object-> eye transformation of a point U defined in object space:

V = R*U+T, where V is in eye coordinates

Suppose that i have four real number Fx,Fy,Cx,Cy. They represents the intrinsic videocamera parameters:
-Fx = focal length * dimension of pixel in horizontal direction
-Fy = focal length * dimension of pixel in vertical direction
-Cx,Cy = coordinates of the principal point

R and T are computed solving the camera pose estimation problem.

In order to obtain the pixel coordinates and render a cube (the cube is rendered (or "registered") perfectly on a planar rectangular target viewed with the videocamera; i print the target on simple hard paper), i do the following:

(eq 1)
x = -Fx*(V_x/V_z)+Cx
y = -Fy*(V_y/V_z)+Cy

I then use custom made routines to draw lines in order to render a wire-frame cube. The rendering is perfect. The cube seems to stay precisely on the planar target and it moves around in the right way.

Now i would like to switch to opengl es rendering, but i am facing a lot of problems.
First, the projection matrix. I have studied the opengl es coordinate transformation pipeline in order to understand how should i setup the projection matrix. To obtain the equation (1), i do the following:

the frustum planes are defined as:
r=right plane
l=left plane
t=top plane
b=bottom plane
f=far plane
n=near plane
the screen width is w, the screen height is h. The viewport
is set at (0,0) of width w and height h. The center of the
viewport is (w/2,h/2)=(ox,oy).

When i look at the planar target from the above (perpendicular to it), the translation in the y coordinate is wrong (if i move up the phone, the cube move up, not down). The rotation part is totally wrong. If i set glR[13] = -T[1], i obtain nearly a correct translation, but the cube do not properly overlap with the cube rendered with my own routines (it is rendered slightly upper than the other).

I really need your help!!!!

Best regards,
Luca

Ps.
The cube i render with my own code is defined as having the bottom side at z = 0,
the top side at z=-1: the two side are defined as