Log in or register to post comments

Integration with JPCT-AE

January 22, 2013 - 2:42pm #1

Hi!

 

I am trying to itnegrate QCAR's Vuforia with JPCT-AE and I am close to the perfect solution. I've read this post and I think I might have a similar problem. 

 

So far I've edited ImageTargets native code so that nothing is rendered, only the modelview matrix is sent to my java code, with a proper 180 rotation on the X axis, like this:

 

 

const QCAR::TrackableResult* result = state.getTrackableResult(tIdx);
const QCAR::Trackable& trackable = result->getTrackable();
QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());
 
 
SampleUtils::rotatePoseMatrix(180.0f, 1.0f, 0, 0, &modelViewMatrix.data[0]);
// Passing the ModelView matrix up to Java (cont.)
env->SetFloatArrayRegion(modelviewArray, 0, 16, modelViewMatrix.data);
env->CallVoidMethod(obj, method, modelviewArray);
 
 
I then use this matrix directly on my camera, and then I can see the object in place. At first the object moved a little bit if I moved the device, but then I sent FOV and FOVY, updated it on my engine so they match, and this movement was suppresed.
 
The problem now is, if I rotate the device "around" the pattern, the object moves slightly. It's not very much but it definitely does not behave like the native example you provide.
 
Where do you think the propblem might be? Maybe I missed some step?

Integration with JPCT-AE

September 29, 2014 - 3:06am #14

I get confused when integrate User Define Target with jpct... so far i already change the render in UserDefineTargetRender.java from openGL to jpct-ae..but it crash..and what is RefFreeFrame for??thanks for your help.

Integration with JPCT-AE

July 12, 2013 - 7:54am #13

Hi, you have posted the same question at the top of this thread:

https://developer.vuforia.com/forum/android/how-can-i-add-3d-object-animated-d

I replied there (please, avoid double-posting). Thanks.

 

Integration with JPCT-AE

July 12, 2013 - 7:18am #12

Hi,

 I have integrated the CloudReco with JPCT-AE and model is loading properly. But if I move the device up(target goes down on the screen) then the 3D object goes right, and move device down then the 3D object goes left.

Please let me know how could i solve this problem.

Thanks & Regards,

Prakash V

Integration with JPCT-AE

February 5, 2013 - 6:10pm #11

Hi,

Thanks for the reply.

Actually, in my case, I do have some complicating UI layout on the activity, and that's why I need to set the orientation to portrait mode.

so how do I tell JPCT that the orientation has changed to portrait mode?

Does it mean that can be done by calling the method "setOrientation" of "Camera"?

or I can simply create a new FrameBuffer with proper width and height?

Thanks again!

regards,

Mason Hsiung

Integration with JPCT-AE

February 5, 2013 - 9:52am #10

You need to tell jpct that orientation has changed, or you'll be using a framebuffer with the wrong proportions when you switch to portrait. You can either let it know whenever vuforia switches orientation, or simply force it to be landscape, which is what I did. if you don't have any UI layout that needs to change with orientation, it really has no advantage to behave differently depending of orientation (or I can't see it).

Integration with JPCT-AE

February 5, 2013 - 9:25am #9

Hi,

I follow the samy way(http://www.jpct.net/wiki/index.php/Integrating_JPCT-AE_with_Vuforia), and found that this works only under landscape mode, if I set the activity orientation to portrait, then the 3D object can't be sticked on the target.

For example, If I move device up(target goes down on the screen) then the 3D object goes right, and move device down then the 3D object goes left.

It's pretty weird...

Any idea?

Thanks.

regards,

Mason Hsiung

Integration with JPCT-AE

January 24, 2013 - 3:57am #8

Glad to hear that. Nice!

Integration with JPCT-AE

January 24, 2013 - 3:51am #7

I finally solved it. I got the same results with your solution than with the modelview matrix. Turns out my objects were badly positioned by jpct-AE (somehow they were what would be "inside" the marker, so I was seeing part of the object that lied "beneath" it.

I moved the cube and it works now :)

 

Thanks for your kind help

Integration with JPCT-AE

January 23, 2013 - 6:33am #6

Hi,

    Thanks, I will try that, but how would you convert those three orientation vectors into something to "look at"?

The lookAt() function requires a point (in JPCT this is a SimpleVector), which you can derive from the camera position and the camera viewing direction;

mathematically this is simply given by this vector sum:

lookAtPoint.x = camera_pos.x + camera_dir.x
lookAtPoint.y = camera_pos.y + camera_dir.y
lookAtPoint.z = camera_pos.z + camera_dir.z

jpctCamera.lookAt ( lookAtPoint ); 

 

An even better solution is to use the setOrientation() method of JPCT, which also allows you to specify the UP vector explicitly (where the UP vector is something that you have, as explained in the FAQ post I was referring to)

 

About the FOV, that implementation looks good; perhaps I would suggest to LOG the values of those two FOV, to see if they are actually reasonable values.

 

 

 

Integration with JPCT-AE

January 23, 2013 - 6:19am #5

Thanks, I will try that, but how would you convert those three orientation vectors into something to "look at"?

 

PD. as for the FOV/FOVY, I gather both from QCAR like this:

 

 

const QCAR::CameraCalibration& cameraCalibration = QCAR::CameraDevice::getInstance().getCameraCalibration();
QCAR::Vec2F size = cameraCalibration.getSize();
QCAR::Vec2F focalLength = cameraCalibration.getFocalLength();
float fovyRadians = 2 * atan(0.5f * size.data[1] / focalLength.data[1]);
float fovRadians = 2 * atan(0.5f * size.data[0] / focalLength.data[0]);
 
and then feed them into JPCT-AE's camera.

Integration with JPCT-AE

January 23, 2013 - 1:06am #4

Hi,

I would recommend that you read this post here:

https://developer.vuforia.com/forum/faq/technical-how-do-i-get-camera-position

This article is very quick to read but it contains a very detailed explanation of the QCAR modelview matrix (how are the axis defined, etc.) and the necessary code to extract:

1- the camera position

2- each of the 3 orientation axis of the camera (i.e. the camera direction, the up vector and the right vector)

If you follow that, and you extract those information (position + orientation vectors) as shown in the post, then you should be able to easily setup your Camera position and oritentation (e.g. you could use the setPosition and the lookAt() method in JPCT) and have a correct camera behaviour.

Using the modelview matrix direcly in JPCT (like you are currently doing) is not a bad idea in general, however it can be tricky and introduce subtle errors due to the different axis system of Vuforia and JPCT.

Concerning the FOV, it is also important to set those values correctly; if you use a certain horizontal Fov, you should also make sure that the vertical Fov is derived from the horiontal one by using the aspect ratio of the viewport.

 

Integration with JPCT-AE

January 22, 2013 - 11:36pm #3

No, it was behaving worse. Without the fov/fovy the model also displaced when moving the phone (even in parallel to the target), now it's less noticeable (but it is yet) and it only happens when you turn around the target.

 

I.E. if you face the target from a top-down position, then it loos like it's centered, but if you look at it from the sides it looks displaced, and it shows.

Integration with JPCT-AE

January 22, 2013 - 11:03pm #2

Hi, so, just to be sure I understand it:

was it behaving correctly before setting the FOV X / Y ?

 

 

Log in or register to post comments