Nicla Vision AprilTag detection runs out of memory

Hello everyone,

I am trying to detect a set of AprilTags from the 36h11 family with an Arduino Nicla Vision board. I am using the sample sketch, and I have set the resolution to HQVGA and I am using grayscale. The resolution should be fine since according to this post, it requires roughly 16x the memory of the frame buffer to process the image. The resolution is 240x160 so 16x that should be around ~0.6MB since the Nicla Vision has 1MB of RAM it should be more than enough to process the image. It is also of note that I do not get any out of memory errors but it also does not detect the tags either.

Only searching in a 100x100 ROI works most of the time but that sometimes causes memory errors “MemoryError: Out of fast Frame Buffer Stack Memory! Please reduce the resolution of the image you are running this algorithm on to bypass this issue!”.

Does anyone have any idea why this is happening? Is there a way too fix this (except for reducing the resolution of the image since memory should be more than enough).

Thank you for your time.

Hi, the Nicla doesn’t have 1MB of continous RAM. ST implemented the memory in different regions and you also need to store the image too. Anyway, it comes down to like 400KB that we can store for AprilTag memory.

So, the Nicla can only do 160x120. This is the same limit as the H7 regular.

Yes, the algorithm has already been heavily optimized. We turned all the knobs years ago. The fact that it runs on an MCU is amazing in itself.

Alright thank you. The 1MB claim was based on what it says on the Arduino website. I naively assumed that all of it would be just “available”.

Kudos to you guys. I am always impressed by how much is possible nowadays. :slight_smile:

Yes, the processor has 1MB of RAM but it’s split over a bunch of different areas. So, only 400KB is usable for the frame buffer to store the apriltag data structure.

Note that a lot is going on though in other areas so don’t think that the other bits of RAM are doing nothing.