A couple requests which will presumably end up being deferred to later iterations of the AprilTag code, but whose absence I find slightly puzzling in the current setup.
- There’s no reason whatsoever why an AprilTagClusterDetection should not be provided with an ID number. Simply pick a standard, such as “the smallest tag ID number of the tags in the cluster”, and return that. Being forced to reference a cluster only via a string identifier forces string matching (which can be slow and/or create memory leaks) into code which might have to exist in the “hot path”. Then they can do integer comparisons instead of being forced to use clumsy human-readable names to identify the clusters. When implementing this, please do so by putting detection.id as a field inside the abstract AprilTagDetection parent class. This would allow us to skip casting to AprilTagClusterDetection in perhaps 90% of use cases.
- Similarly, there’s no reason why the .metadata fields of both AprilTagSingleDetection and AprilTagClusterDetection should not implement an interface (say, IAprilTagDetectionMetadata) which guarantees the existence of the .name property, and for the abstract parent class to at least promise that its children will have a .metadata property which implements this interface. That would take only a couple lines of additional code in the SDK, but would further simplify the kids’ code as they can ask any AprilTagDetection for .metadata (even without casting), and ask that .metadata for its .name property if they want to.
Basically, forcing them to cast to the relevant subclass is annoying, significantly complicates the learning curve at a stage which is already fairly fiddly, and is largely unnecessary with a couple of fairly simple changes. I’ve got junior high schoolers in some of the teams I’m helping, and with this year’s SDK, the AprilTags section has pretty much taken the step from “tricky but learnable” to “might as well be black magic.” I grok what you’re going for at the advanced end with the distinction… but let’s please try to make the distinction between clusters and single tags something that the advanced students can take advantage of, but the rookies aren’t forced to learn right away!
- Eric Finley