JPCT + Vuforia in stereo rendering mode

Started by thejauffre, April 11, 2018, 10:15:19 AM

Previous topic - Next topic

thejauffre

Hi everybody,
I'm working on a project in which I have to perform stereo rendering (using smartglasses and/or a VR viewer) using Vuforia and JPCT-AE. I am working on the DigitalEyewear example.
I followed the instructions to integrate Vuforia and JPCT in the mono rendering case, as explained in the wiki, and tried to replicate them to the stereo-rendering without success.
This is what I understood: in the mono-rendering, I just had to find the modelview matrix associated to an image target, then update the JPCT camera and start the rendering. I tried the same for the stereo case, taking into account that Vuforia has to simulate the views of the two eyes, using two virtual camera FOVs; this kinda works, but the object is not correctly displaced in the scene (i.e. I expect it to be on the origin, but it is somewhere else).
I tried to solve this problem in several ways (i.e. rotating/rescaling the modelview matrix or multiplying it by a projection matrix) but it doesn't work.
Any ideas? Thanks.

EgonOlsen

The approach sounds reasonable, I guess. Is the object rotated correctly and "just" the translation is wrong!?

thejauffre

Well, if I use just the modelview matrix to update the camera, i don't even see the object.
If I rotate the modelview matrix of -90 degrees about x axis, I can see it, in a wrong position/rotation of course (but at least it is visible).

EgonOlsen


thejauffre

Yes, if I use just the modelview matrix without any modification (as in the wiki) the object is displaced correctly.

thejauffre

Ok, I found the problem: the size of the image target inside the database was not the same as I expected, so I guess it was just a problem of sizing.
Thanks :)

EgonOlsen


thejauffre

Hi! i'm sorry to bother, but i still have some problems.
Using just the modelview matrix works fine when the video background is active. In fact, when using the smartglasses in see-through mode, Vuforia applies a projection matrix (retrieved after a per-user calibration process) to correctly display a virtual object on the scene, so that the viewer sees it on the marker, like if it was real.
So, i'm trying to use the same projection matrix on JPCT, and, by forcing it touse the same near and far planes as Vuforia, i am able to see the object right over the marker.
However, the rotations of the object are messed up: it's like I'm seeing it from an arbitrary direction, and (for example) when I rotate the marker clockwise, the object rotates counterclockwise. Maybe it is related to the different reference frame used by OpenGL and JPCT. I tried performing a rotation of the final modelviewprojection matrix (namely the product of modelview and projection mats) about 90 deg about x-axis and a negative scaling on the z-axis, but it has the same problem.
Any ideas?

thejauffre

Ok, i managed to solve part of the problem by tuning the FOV and near/far plane of JPCT camera (as i read here in the forum, applying Vuforia/OpenGL matrices is not recommended).
Now I can see the object (a square) almost on the marker, but it is stretched: it's like the horizontal side is larger than it should be.
I checked the framebuffer size, tried to change the FOV values and the planes, but nothing changed.
What could be the problem?

EgonOlsen


thejauffre

Sure.
In the archive there are two screenshots (their names are self-explanatory).
I got the "correct" one by scaling the modelview matrix along the x direction, but this is like cheating (in fact, if I rotate the marker, the object will be stretched)

EgonOlsen

If you've played around with the fov settings...have you just changed fov or yfov as well?

thejauffre

#12
I changed both. X and Y FOV are set to PI/8.5 and PI/17 respectively. However, I'm noticing that changing them does not affect the rendering - which is strange. Maybe I messed up with something, gonna check it.


Edit: Ok, changing the values of the FOVs the rendering is not stretched anymore (i put fov=1, fovY = 0.55). Still, I need to decrease fovx to a smaller value (basing on some calculations, I need it to be around 20 degrees); setting it to values lower than the unit causes the deformation, no matter the value of fovY.

Edit2: "accidentally", i found the setFOVLimits method. Well, now I can set the FOVs as I like :D

EgonOlsen

Yeah, sorry about that method. I should have mentioned it and I really can't remember why I put that in...