Skip to content
Hive Vision

Webcam Tuning Guide

Learn how the HSV color ranges and the shape and size gates in BallDetectorPipeline.java decide what counts as a game piece, and how to re-tune them for your field.

The Webcam pipeline has no model to configure. Everything it knows about a game piece lives in a handful of constants at the top of BallDetectorPipeline.java, in two groups: HSV color ranges, and shape and size gates.

The defaults were learned from the Limelight neural network on real match footage. If your lighting or camera is different, change the constants in this file.


Each color is matched as a lower and an upper HSV bound, using OpenCV’s scale: H 0–180, S 0–255, V 0–255.

Color Hue (H) Saturation (S) Value (V)
Yellow 9 – 33 90 – 255 45 – 238
Red 0 – 15 and 170 – 180 81 – 255 45 – 232
Blue 102 – 128 80 – 255 45 – 247

After a color mask is built, each blob is only kept if it passes these gates. Area values are in pixels at your camera resolution, so scale them if you are not on 1920 x 1080 (see step 7 of Webcam setup).

Constant Default What it does
MIN_AREA_PX 900 Removes speckle patches
MAX_AREA_PX 12000 Removes big robot panels
MIN_ASPECT / MAX_ASPECT 0.71 / 1.4 Keeps near-square blobs only
MIN_FILL / MAX_FILL 0.5 / 1.3 Compares the contour area to the area of its bounding rectangle
EXPECT_YELLOW_AREA 3500 Typical real yellow pollen contour area
EXPECT_RED_AREA 4200 Typical real red nectar contour area
EXPECT_BLUE_AREA 4200 Typical real blue nectar contour area

Measured against the neural network’s detections on the development match video:

Color Recall Precision
Yellow 68.7% 39.9%
Red 80.1% 26.0%
Blue 82.3% 65.5%

  • Nothing is detected: check that the webcam name matches the Driver Station configuration, then widen the saturation and value minimums slightly.
  • A color is missed in dim light: lower the V minimum (the third value in the lower bound) for that color.
  • Boxes appear on the wrong objects: raise the S minimum for that color, or tighten MIN_AREA_PX and MAX_AREA_PX.
  • Detection stopped working after changing resolution: scale the area constants as described in Webcam setup.