Start a new topic

getDistanceToImageTarget(ImageTarget other) return also the distance from camera?

 Hello, I'm trying to make an application which, having two targets recognized, display a content between them, into a region defined, on x axis, by the distance from every target to each other. Targets are strictly 2.

In Java I am implementing a method, into the overrode "public void onImageTracked" this method make uses of  getDistanceToImageTarget(ImageTarget other), to get the float showing the distance between target 1 and target 2.. this work and, indeed, the box around one of the two target is right formed and it grow up accordling, as the distance between the two one increases... However the other target responds to the distance from camera.
In debug i can see that, intermittently, the getDistanceToImageTarget returns two different values: one set as distance between targets, one set as distance from camera. On second target the distance of camera's value is bond(!)

here's my code

primo and secondo are initialized above in the script and are firstTarget and secondTarget

// check if firstTarget and secondTarget are not null (both must exists. As one target disappear, to avoid Java Null pointer dereference, in onImageLost, every time one of the pair is lost I reinitialize both  as null
(primo != null && secondo != null) {

float distanceBetween = secondo.getDistanceToImageTarget(primo);
} else {
} // returns in debug example: // 2383.0 (distance from camera!) // 607.0 (distance between targets: the value I need) // 2383.0 // 607.0 ..... ad libitum

What am I doing wrong?

1 Comment

Hi Gabriele,

based on our internal code I don't see how this could happen. Would it be possible to see more of the code surrounding the snippet you posted? Also, which version of the SDK are you using?

- Daniel

Login or Signup to post a comment