Log in or register to post comments

Distance problem

July 18, 2011 - 2:29am #1

in the imageTargets Template how to calculate the distance between marker and the cell phone after 3D model is displayed.

Re: Distance problem

August 11, 2011 - 12:03pm #6

Tyro, thanks for your hints. Got it!

I will use the Unity extension too, how can I access the model view or pose matrix from within unity? i.e. TrackerBehaviour.PoseData is not accesable due to protection level.

Thank you very much in advance!
Edit/Delete Message

Re: Distance problem

August 10, 2011 - 7:29am #5


The code that's shown is from the ImageTargets sample that's provided w/ the native SDK from this site. When you install the SDK, you'll find a samples directory in its path, and ImageTargets is one of the samples.

e.g. C:\Development\Android\qcar-sdk-1-0-0\samples

Within the ImageTargets project directory there's a C++ file named ImageTargets.cpp in the /jni directory. The _renderFrame method is part of this code, and shows how to work with the modelview. I think that all of the samples use a similar structure and conventions and so the _renderFrame method is used in all of them.

Re: Distance problem

August 9, 2011 - 9:37am #4


I am very new to the SDK so I did not got it yet :(

How can I obtain the ModelViewMatrix ? and in which script to I find _renderFrame?


Re: Distance problem

July 18, 2011 - 8:17pm #3

Thank you so much!!!! I got it

Re: Distance problem

July 18, 2011 - 5:30am #2

in _renderFrame, after you have obtained the modelViewMatrix, you can determine the target distance by the square root of the sum of the squares of the coordinates of the target position.


        QCAR::Vec3F position(modelViewMatrix.data[12], modelViewMatrix.data[13], modelViewMatrix.data[14]);

        float distance = sqrt(float( position.data[0] * position.data[0] +
                            position.data[1] * position.data[1] +
                            position.data[2] * position.data[2] ));
LOG("distance: %f", distance);

Log in or register to post comments