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.
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.
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