AprilTag detection resolution


I’m using the H7 for AprilTag detection. I’m trying to get as much resolution as I can while staying within memory limits.

What’s odd is that when selecting certain windows AprilTag detection stops working at all, with no error. This is staying with multiples of 8. I started at 240x240 which hit out of memory error, so I reduced the window until 224x224 where I no longer get a memory error but there’s no detection of AprilTags at all, using either the 25H7 or 36H11 families.

No window will successfully detect anything in resolutions in multiples of 8 from 224x224 down through 184x184, regardless of lighting or closeness. Then at 176x176 it works perfectly. 176x184 actually works too. This is using the QVGA frame size. Firmware 4.1.4, sensor set to grayscale. I am using the ‘Max Res’ example code but adjusting the frame size and window.

Is this still a memory issue though it is not throwing memory errors? Or am I doing something wrong?


Uh, it’s just trashing at those resolutions. It’s still running out of RAM, but, it doesn’t hit the condition of being completely out per Malloc.

Internally AprilTags builds these lists of points on the edge of a tag. Each realloc of the point list as it grows can fail. If that fails I toss the point list but don’t error out. When it runs out of RAM this because another part in the code is low on memory like when allocating giant fixed buffer.

Anyway, when the point lists are being realloced and that fails you get no detections. Note that this happens occasionally on the working res but not enough to cause massive issues. Once you reduce free RAM for the algorithm below a certain amount then this issue starts happening and causing tags to be impossible to decode.

If you want more resolution use set windowing to reduce the QVGA resolution save RAM.

Thanks Kwabena, that makes sense. I’m using QVGA windowed to 160x160 and it’s working perfectly.