Reputation: 4328
Is it possible to find the distance of the device from the Image Target of Vuforia.
If there's no standard way, one approach would be to build an algorithm that uses Gyroscope and Accelorometer readings to keep tracking changes from an initial distance (how to get this distance, by the way?)
Basically, I want to know the position and orientation of the device relative to the image target. Suggest the best ways.
Upvotes: 2
Views: 1426
Reputation: 2711
First of all, getting the distance via the sensor is only possible if you 'force' the user to first put the device on the image target, and then move away. It seems problematic.
I do not know if in Unity there's any special way, but basically in raw openGL the distance is simply sqrt(x*x + y*y + z*z)
. Do note, if you are seeking a metric value, this is problematic since it depends on the size you have defined the original image to be when you have created the Vuforia Dataset, and on the size of the target the use is detecting.
Regarding the rotation of the target (which is relative to the camera), you can get it from the target pos matrix (if you are unfamiliar with this, do some reading on the Vuforia articles).
Upvotes: 1