-
Notifications
You must be signed in to change notification settings - Fork 0
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
Apriltag filtering #2
base: master
Are you sure you want to change the base?
Conversation
constexpr int LEGAL_TAGS[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; | ||
|
||
// Load config for legal tags | ||
std::vector<int> LEGAL_TAGS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this PR was just extending the previous code which worked with a vector. But there's a potentially better way to do this.
C++ has a std::set data structure which is a perfect fit for this. It's a structure which simply tracks members of a set. In this case, you'd set it up with the tags IDs that are valid, and then in the detection loop just check that .count() is non-zero (it's going to be either 0 or 1, the .count() function is used by the container to be compatible with other data structures where count can be any value).
This set will take a slight bit of extra work to set up (read the param into a vector, then loop to .emplace() each entry from that vector into the set) but the lookup will be quicker and easier to read.
Speaking of which, it looks like the code currently re-reads the param each time an image is processed. Instead, this param read should be made part of the ApriltagDetectorNode constructor and the set data structure stored as a class member. No need to re-read the config value every image when it won't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the suggested changes to apriltag_detector_node -- it seems to be working based on my testing -- and currently working on the GPU port. Thanks so much for your help!
One more idea, once this is working for the CPU apriltag code, port it over to the code in gpu_apriltag/src/gpu_apriltag_nodelet.cpp |
Add config to select which apriltags are valid