Hello,
I am beginner in Vuforia, I’m trying to calculate the distance between the AR camera and an image target via Vuforia on Android, I found this code on the vuforia forums but when I try it, I don't get the good results.
TrackableResult result = state.getTrackableResult(tIdx); Trackable trackable = result.getTrackable();
Matrix44F modelViewMatrix_Vuforia = Tool.convertPose2GLMatrix(result.getPose());
Matrix44F inversMV = SampleMath.Matrix44FInverse(modelViewMatrix_Vuforia);
Matrix44F invTranspMV = SampleMath.Matrix44FTranspose(inversMV); float cam_x = invTranspMV.getData()[12]; float cam_y = invTranspMV.getData()[13]; float cam_z = invTranspMV.getData()[14];
Log.v("QCV", "Posx=" + cam_x + ",posy=" + cam_y + ",posz=" + cam_z); float distance = new Float(Math.sqrt(cam_x * cam_x + cam_y * cam_y + cam_z * cam_z)); Log.v("distance ",""+distance);
Can you help me please ? is there another function or code to calculate the distance?
Thanks