Image Tracking - How to get the image index of each image, each time it's looked at

Hi, is there a way to get the index of the image being tracked continuously?

I would like to set game objects in the Hierarchy active when an image is being viewed, and deactivate them when another image is being viewed. Currently I can get this to work for the first time you view an image, but if you go back to look at a previous image, it won’t reactivate the content if it’s already been viewed.

From what I can see, you can only set NRTrackableQueryFilter to either ‘New’ or ‘All’. ‘New’ only gives you the number for a new image you’ve not looked at, and stops giving out an index number after that first time. ‘All’ gives out multiple indexes of the images you’ve viewed, one after the other.

Is there a way to use GetDataBaseIndex() for every image you view, regardless of whether you’ve already viewed it or not?

If so, could you post an example? I’ve tried a lot of variations, and can only get this to active/deactivate for the first time viewing an image :-S

Hi, maybe you can try the following pieces:

///Get the id of trackable.

/// The data base index.
public int GetDataBaseIndex()
UInt32 identify = TrackableSubsystem.GetIdentify(TrackableNativeHandle);
identify &= 0X0000FFFF;
return (int)identify;
(The piece of codes are from NRTrackable.cs)

Then create a new function to detect the tracked images and include the scripts above.

If I debug.log GetDataBaseIndex() from your Image tracking demo scene for example, it will only retrieve the index the first time an image is viewed. So say I have 3 images, if I look at each of them one after the other, this is fine. If I then go back to the first image that’s already been viewed, it doesn’t log anything.

I think it’s something to do with not treating it as a new image?

Hi, You can change the NRTrackableQueryFilter.New to All, as I did. This will result in the index being printed while the image is being viewed. Keep in mind that the printed index will be shown in every frame, so you may want to control the frequency according to your specific requirements.

Hi, I tried that already, it spits out every number of the images it’s already viewed?

From what I tested, it recognized the images every time I viewed them including the images already viewed, as you can see what the following log.

Where in the code are you getting those results with the debug?

Please check the following codes:

For me, putting the debug there still only prints the number out once per image, even when the filter is set to ‘All’.

I’m wanting to case the index number, but can only ever get it to give me the number once per image. So it fails if you look back to a previously looked at image.

Which version of SDK did you use? Also, please send me your Unity project if possible.

I’m using 1.10.1, as I needed the experimental version. It’s to be built to the dev kit so can only go as high as 1.10.2 anyway.

I’m not allowed to send the files unfortunately. But the problem occurs in the image tracking demo scene of a completely fresh file, which is where I tested the debug you posted above. I don’t get a peristent reading on the index number, only when an image is looked at first time, regardless of ‘new’ or ‘all’, which just seems odd

Tried it again in a clean project, with the code you posed above. The debug puts the correct index number only for the first time you look an an image. If I go back to an image looked at previously, there’s no index debug call. I’m not altering any code, other than what you highlighted

I tested the V1.10.2, it also printed the index when I looked back at the previous image. Please replace your TrackingImageExampleControl.cs with the following file. Also, I attached my test app, you can have a try.

Hi, thanks for your reply.

I still don’t see it logging the number each time. If I were to try to case the returned index number. It works the first time an image is viewed and not a second?


Any further advice on this? Even if it’s just how to show different objects on different images?