Tracked image manager fails with multiple images

Hi there.

I’m using an image detection library to generate different prefabs on different images. I have 5 images altogether. I want to be able to point the camera at the image and generate a prefab depending on the image (it’s christmas themed, so, an elf on an elf picture, santa on a santa picture etc)

this is the code I was trying. No prefabs yet, just checking that it recognised the images and updated them.

void onTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs)
{
    foreach (ARTrackedImage trackedImage in eventArgs.added)
    {
        addedCounter += 1;
        whichImageAdded = trackedImage.referenceImage.name + "";
    }

    foreach (ARTrackedImage trackedImage in eventArgs.updated)
    {
        updatedCounter += 1;
        whichImageUpdated = trackedImage.referenceImage.name + "";
    }

    foreach (ARTrackedImage trackedImage in eventArgs.removed)
    {
        removedCounter += 1;
    }

    addedText.text = addedCounter + "";
    updatedText.text = updatedCounter + "";
    addImage.text = whichImageAdded + "";
    updatedImage.text = whichImageUpdated + "";
}

I’ve been getting some strange but consistant results.

When I scan each image in turn, it will always recognise the first image it looks at and update it.
It will add the remaining four images but it will only give update info on two of them.

I’ve tried looking at the images in different orders. The first image is always recognised, so I don’t think the problem is with the images themselves.

Also, by the time the addCounter gets to 5 (the number of images in my Image Recog Library), it will only update the last successfully recognised image and never recognise anything else.

Has anyone come across this behaviour before?

Can you describe the failure you are seeing? You’re saying it only sends updates for two images, but that doesn’t mean the other images don’t exist, can you describe how the images look when you have five images tracking, or what is happening when you attempt to track five images?

thanks for your reply. I’ve tried to take down this question because the code actually works fine but I was looking at the wrong thing.

The code was printing out which images were “added” and which were “updated”. For some reason, it would only register 3 of the 5 that were “updated”.

However, I changed it to print out the trackingState of each image - tracking, limited or none - and it was doing what it was supposed to do.

Not sure how to remove the question from the forum though.