"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

The distance from the trackable to the camera

Hi,

 

I am new to Vuforia so I started with the SampleApplication in Android with Java. What I am trying to achieve is to recognize some object and compute the position of the object to the camera. Like how far is this object to the device. 

 

When I looked into the code for the SampleApplication.Object Reco, I see that it renders a bounding box on the object in scene and the size of the box is changing when the object moves away from the camera. I notice that the App uses the getPose() API on the trackableResult and get a modelViewMatrix. But I couldn't fully understand the math behind the scene and figure out how to compute the distance. My idea is that if I can get the size of the object on screen, combinded with the size of the object in database, I can know the difference in distance.

 

Thank you in advance for any help.

 

 

Hi,

Here is more information regarding the camera projection Matrix: https://library.vuforia.com/content/vuforia-library/en/articles/Solution/Working-with-the-Camera.html#How-To-Use-the-Camera-Projection-Matrix

Thank you.

Vuforia Engine Support

mich94hj

Sun, 05/24/2020 - 21:47

In reply to by mcotora

I am not too familiar with the pipeline of OpenGL and the math of modelViewMatrix. Is there a straighforward way to compute the distance from the tracked object to the camera given the size of the object?