# Adding image to ARImageDetectionManager not working, array is 0

**URL:** <https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525>\
**Category:** I'm Stuck\
**Created:** [August 20, 2022, 3:57pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525 "2022-08-20T15:57:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 20, 2022, 3:57pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/1 "2022-08-20T15:57:27Z")

</div>

_Include the following details (edit as applicable):_

- **Issue category** : Semantic Segmentation
- **Device type & OS version** : iOS
- **Host machine & OS version** : Mac
- **Issue Environment** : Unity Mock
- **Xcode version** :13.4.1
- **ARDK version** : 2.0.0
- **Unity version** : 2021.3.1f1

Description of the issue:

I’m trying to run this code, the reference to the ArImageDetectionManager is fine I think, get no errors, with Sync or Async methods:

```auto
public void AddImageToSession(Texture2D tex)
    {
        var _physicalImageWidth = 1.0f;
        byte[] rawByteBufferAsync = tex.GetRawTextureData();
        IARReferenceImage _yetiImage =
            ARReferenceImageFactory.Create
            (
                "yeti",
                rawByteBufferAsync,
                rawByteBufferAsync.Length,
                _physicalImageWidth
            );
        _arImageDetectionManager.AddImage(_yetiImage);
    }

```

Once it’s run, the array inside the unity Editor stays at 0, when I’d expect to see the image I’d passed being inside.

The image I’m trying to pass is the Mock-Crowd image that comes with the examples.

Anyone got any ideas?

---

<div class="post-metadata">

**Author:** ![Gilberto](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@Gilberto](https://community.nianticspatial.com/u/Gilberto)\
**Post date:** [August 22, 2022, 11:11pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/2 "2022-08-22T23:11:40Z")

</div>

Hi @Chris_Barry  
Kind of hard to say from just the snippet… Also assuming that by `the array inside the unity Editor stays at 0` you mean `rawByteBufferAsync`.  
Can you give me a bit more info on how you are setting this up? When I try your code with a super basic script like this:

```auto
    public ARImageDetectionManager _arImageDetectionManager;
    public Texture2D someImg;
//...
    void Start()
    {
        AddImageToSession(someImg);   
    }
//...

```

I can see that the \_yetiImage is added, and I can access info from it. so yea need a bit more info on this.

---

<div class="post-metadata">

**Author:** ![Umaiya\_Doddamani1](https://avatars.discourse-cdn.com/v4/letter/u/439d5e/32.png) [@Umaiya\_Doddamani1](https://community.nianticspatial.com/u/Umaiya_Doddamani1)\
**Post date:** [August 22, 2022, 11:32pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/3 "2022-08-22T23:32:59Z")

</div>

Hi Chris,

Unfortunately, I was unable to reproduce the issue you are observing. I could detect Yeti and Crowd images as in the ImageDetection example. I also detected the Mock-Crowd image by copying that jpg to the same directory as Yeti.jpg or Crowd.jpg, creating Mock-Crowd.jpg.bytes file and using it as Reference Image Input (in ExampleManager Inspector window).

Pls Note: The image Detection example works only on APP, not in the unity editor. So please try to deploy your app to the device and point toward the image to be detected.

Also can you please confirm that you have targeted the image which you want to load within Unity as well as the code? Please refer to this [Image Detection](https://lightship.dev/docs/ardk/ar_world_tracking/detecting_images.html#detecting-images) documentation.

If the issue still persists, please reply to this post with any log information you are seeing, any screenshots with error messages, or any other details that you may have which might help us to repro the issue.

Thanks.

---

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 23, 2022, 10:21am UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/4 "2022-08-23T10:21:33Z")

</div>

Hi,

When you say it only works on the app, does that mean I wouldn’t see the images in \_arImageDetectionManager go up when adding them to that?

And also, if it only works in the app, why is there a Mock Image Anchor? Presumably you just mean the example you have built only works on the app, not that the whole image detection system doesn’t preview in editor?

I’ll try some more things out, but it sounds like you are confident something should be working my end, so I’ll keep trying.

Cheers,

Chris

---

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 23, 2022, 10:31am UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/5 "2022-08-23T10:31:43Z")

</div>

> [@Gilberto](#):
>
> `_arImageDetectionManager`

Actually, I mean that the array inside the \_arImageDetectionManager stays at 0, when I would expect to see a new element appear there

 ![Screenshot 2022-08-23 at 11.23.17](https://us1.discourse-cdn.com/niantic/original/2X/4/4d3d981e9e9542c2525d114a5f94a930a0f2bc21.png)

This element in the array is a hardcoded (editor added) one from the example scene in the latest sdk, so I would expect after running the code to see this array go up.

Here is an example (in the latest SDK and unity 2021.3.6f1)

Need to post seperate images

Nothing happens (the array does not increase in size) and no errors are generated.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 23, 2022, 10:32am UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/6 "2022-08-23T10:32:14Z")

</div>

![Screenshot 2022-08-23 at 11.29.34](https://us1.discourse-cdn.com/niantic/original/2X/7/7b62751746b7928e5828575a852df961a44774d8.png)

Manager next to script to add image programatically

---

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 23, 2022, 10:32am UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/7 "2022-08-23T10:32:53Z")

</div>

And the code of that component

 ![Screenshot 2022-08-23 at 11.30.41](https://us1.discourse-cdn.com/niantic/original/2X/c/c54be1a36c095758f29ebb56450563b52579b371.png)

---

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 23, 2022, 10:35am UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/8 "2022-08-23T10:35:28Z")

</div>

And I tried a different tex2d here:

 ![Screenshot 2022-08-23 at 11.34.40](https://us1.discourse-cdn.com/niantic/original/2X/2/2dd3340082796bcefcf679476e1fb194edc96448.png)

Remember, the crowd element is a manual one in editor, I’d hope to see new elements popping up in the array…

---

<div class="post-metadata">

**Author:** ![Umaiya\_Doddamani1](https://avatars.discourse-cdn.com/v4/letter/u/439d5e/32.png) [@Umaiya\_Doddamani1](https://community.nianticspatial.com/u/Umaiya_Doddamani1)\
**Post date:** [August 23, 2022, 8:41pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/9 "2022-08-23T20:41:32Z")

</div>

Hi Chris,

Yes, as I mentioned earlier. No changes will show in the Unity editor because the image detection example scene only works on devices. Once you build an Image Detection scene on your device, you are able to detect an image with your phone camera and replace it with an AR asset.  
Please see the attached screenshots for your reference.

![](https://lh5.googleusercontent.com/MsCFuLJRVOPoiT1CqTAmhNJqdFqZnky0Odv1f1Is8a9ZkErh21FfqRgJdk8I4QHAT2cd4Uv4vO-QhkTelu-Ayqj4STLfj-CFqlkHGWW5YQk16w_Ks94xmonF2s0JF98O-BUffDfMpIE3DkAgw7u53w)

![](https://lh6.googleusercontent.com/GNYeOvIu8KcUhLQOsRk3hwj2OzDAdrZLT_I5O4HgYCvKamqBO-L1IhhAGJ7znBKdget4qRKf74H1CqHRvzLakrIJiMbpCxyVqG-YNmUYy4VwSyWBOBPM0xwXa8a5Z9O7rFPla6dOgioz5r9uFKrW7Q)

---

<div class="post-metadata">

**Author:** ![Chris\_Barry](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/chris_barry/32/1119_2.png) [@Chris\_Barry](https://community.nianticspatial.com/u/Chris_Barry)\
**Post date:** [August 25, 2022, 4:20pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/10 "2022-08-25T16:20:53Z")

</div>

Hi @Umaiya_Doddamani1 ,

Thanks for your feedback 🙂 OK, so I will have to assume this works and try on the device. What was confusing is that you said that the example scene does not work on the editor but only on device? That’s fine, but it’s the ARImageDetectionManager that I am trying to get that to work (in another scene, not inside the example scene, although I was trying that as well of course) so to be clear, it’s not possible to see ARImageDetectionManager running in the editor?

If this is the case, what is the point of having this mock - [Detecting Images — Niantic Lightship Augmented Reality Developer Kit release-2.1 documentation](https://lightship.dev/docs/ardk/ar_world_tracking/detecting_images.html#mock-image-anchors)

Kind regards,

Chris

---

<div class="post-metadata">

**Author:** ![Umaiya\_Doddamani1](https://avatars.discourse-cdn.com/v4/letter/u/439d5e/32.png) [@Umaiya\_Doddamani1](https://community.nianticspatial.com/u/Umaiya_Doddamani1)\
**Post date:** [August 25, 2022, 8:56pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/11 "2022-08-25T20:56:29Z")

</div>

Hi Chris,

The latest version of ARDK supports image detection in the unity editor, while the older versions do not. You can use the mock living room scene to detect yeti and crowd images. Here is the [document](https://lightship.dev/docs/ardk/tools/vs_mock_mode.html#mock-image-detection) for your reference.

The InspectorImage in the ARImageDetectionManager is used to provide a way to add reference images in the inspector, while the AddImage function call will not increase the array size.

Thanks,

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [March 5, 2026, 11:50pm UTC](https://community.nianticspatial.com/t/adding-image-to-arimagedetectionmanager-not-working-array-is-0/2525/12 "2026-03-05T23:50:05Z")

</div>

Closed on March 5, 2026, 11:50pm UTC

Age
