Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory allocation #156

Closed
Lexicss2 opened this issue Jun 24, 2021 · 2 comments
Closed

Memory allocation #156

Lexicss2 opened this issue Jun 24, 2021 · 2 comments

Comments

@Lexicss2
Copy link

I would like just to ask regarding the source code.

In apriltag.c there is method called static void quick_decode_init(apriltag_family_t *family, int maxhamming)
and there is a logic for memory allocation.
First, the parameter maxhamming == 2 by default. What chnages if I decrease it to 1 or even to 0. I have a strict memory limitation on my side that is why I am looking the way hoe to decrees memory allocation. When I am doing it the memory allocation is significantly lower, and tag detection is working, but what the side affect of it?
Second, thete is code qd->nentries = capacity * 3; What is the magic number 3 and why we need this multiplition?

@wxmerkt
Copy link
Collaborator

wxmerkt commented Jun 24, 2021

Related discussion: AprilRobotics/apriltag_ros#93 (comment)

@mkrogius
Copy link
Contributor

The maxhamming governs the number of cells in the tag that can be read incorrectly and still have the tag be detected correctly.

The multiplication by three is to create a hash table with a load factor of 33.3%. Setting the load factor higher may result in slower hash table lookups. However, we made the choice of 33.3% here as a choice that has to work for all tag families. If you know you are only going to be using one tag family, you could probably increase the load factor as long as you test that it isn't slowing things down to much.

@wxmerkt wxmerkt closed this as completed Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants