wpilibsuite / 2025Beta

Repository for Beta Testing of 2025 Software
13 stars 5 forks source link

Default AprilTagDetector has very limited tag detection distance #42

Open tom131313 opened 2 days ago

tom131313 commented 2 days ago

2025 beta 1 has AprilTagDetector QuadThresholdParameters minClusterPixels = 300 up from the previous library value of 5. This results in a very limited detection range that is roughly 1/3 to 1/4 the previous range depending on the resolution.

I don't find any documentation of why this was changed and I must set the parameter in code back to 5 to get a useful detector. (I don't consider 3 feet range at my 320x240 a useful default and it was hard to figure out the change without change-log documentation.)

[criticalAngle was also changed for unknown reasons but that doesn't seem to affect detections in my limited testing.]

[My team 10473 is a very low resource rookie team that intends to use AprilTag detection on the roboRIO v2, if possible. AprilTag detector performance tuning hints are appreciated.]

PeterJohnson commented 2 days ago

This was changed as a result of discussions stemming from https://github.com/wpilibsuite/allwpilib/issues/4920. The problem with the default value previously was it allowed too much noise in the result. 200 was originally suggested, but it ended up as 300 when ultimately merged (following a brief discussion in https://github.com/wpilibsuite/allwpilib/pull/5896). The idea was that the defaults should be stricter to give better results, and teams can tune them to be looser if different behavior is desired and they're knowingly making the tradeoff between noise and distance capability.

tom131313 commented 2 days ago

The idea to highlight tuning possibilities is laudable except it was a painful undocumented breaking change. Also, neither the WPILib documentation of AprilTag Adjustable Parameters nor the referenced AprilRobotics documentation mention minimum pixels.

I am interested in the source of noise that some think is excessive and how it is manifest in detections. I haven't seen it unless you are referring to the glare in some arenas and varying lighting, otherwise, all the tags seemed to be in pristine condition. I haven't seen many frames not have their tags detected correctly and essentially none of the failures had the tag id wrong. (I'm ignoring no detections because of movement of a rolling shutter camera - that is largely a solvable problem with a global shutter.)

https://docs.wpilib.org/en/latest/docs/software/vision-processing/apriltag/apriltag-intro.html#adjustable-parameters