How to detect AprilTags in Java (using a logitech webcam). Sample code pls

There’s a Ri3D Redux video coming that shows off doing Apriltag detection on a Rio.

We have example code at Robot2023-Simple/Robot.java at f90a583bcfaa8e3c579e253f3bc003cb2dfba665 · Ri3DRedux/Robot2023-Simple · GitHub

We did have to change the default settings as they let in way too much noise / incorrect readings.
minClusterPixels was increased from 5 to 250. 5 pixels is far too little to detect an AprilTag.
criticalAngle was increased from 10 degrees to 50 degrees to make sure we detect things that are mostly square.

We were able to get 7-11 fps at 480p, which is excellent to stop, detect, and align.

Keep in mind our config values were picked very quickly and spending a little more time can give you better results.

4 Likes