We've been using ImageTracker for a while now as it suited our needs. Moving to more complex objects, we found that ObjectTracker is giving us better detection result. However, with 3D tracker, there's not built-in way to get the distance to the target.
We need the distance to know if we are close enough to take a picture. Is there a way to estimate the distance to the ObjectTarget detected? If I'm able to get the scale of the detected object, I could infer the distance, based on the known size and distance of the object to the camera when I captured the images used to create the model.
Basically, how can I estimate the distance between the camera and the detected target?
Does this forum post help:
Thx and greetings
I'm not using an InstantTracker so setting DeviceHeightAboveGround seems impossible. Even if it was, our object ca be handled while being filmed and is often very close to the environment.
Because of the last point, it's impossible to use the environment to estimate the distance.
Is there a method to extract directly the distance to the ObjectTarget, or at least the scale ? If I can retrieve the scale of the object compared to the 3D cloud points, I can estimate the height of the target. I've tried with target->getTargetScale(), but with no success, as the scale seems to always be around 200 (I don't even now what it means).
From this post: https://support.wikitude.com/support/discussions/topics/5000082528 , the support seems to say that we could get the Z translation from the last column of the viewMatrix. I'm getting a value but how to know what it means ?? How can I retrieve a value in mm or cm for example?
Could you please provide us with details if you work with the JS SDK or the Native SDK? The JS SDK doesn't offer an API to query the distance to the object.
Thx and greetings
I work with the JS SDK. In my Android code, I'm using an adapted
version of your C++ SimpleInputPlugin to get the different matrices
(viewMatrix, projectionMatrix, etc...). Is there a way to extract the
scale of the detected target from that?
Is it possible to get the distance directly from the native sdk ?
As for object targets the only input are camera images, which lead to an arbitrary scale in the creation of the target, there is no automatic way to get the real scale of the object (either cm or mm).
What you could do is using Wikitude Studio to scale your pointcloud in a way that it reflects the real size.
Doing that you could use your current setup to extract the distance to the target from the given viewMatrix.
See: https://www.wikitude.com/external/doc/documentation/studio/studioeditor.html#point-cloud-transformation for more information.
Hope this helps,