Detector pipeline
The detector pipeline locates individual objects in the frame, returning bounding boxes, class labels, and angular offsets for each detected object.Quick reads (NetworkTables)
// Primary detected object's class name
String detClass = LimelightHelpers.getDetectorClass("limelight");
// Primary detected object's class index
int detIndex = LimelightHelpers.getDetectorClassIndex("limelight");
Raw detections (fastest — no JSON parse)
Prefer getRawDetections() over getLatestResults() for time-sensitive detection loops. Raw detections are read directly from NetworkTables and avoid the overhead of JSON serialization and parsing on the Limelight and deserialization on the RoboRIO.
LimelightHelpers.RawDetection[] detections =
LimelightHelpers.getRawDetections("limelight");
for (LimelightHelpers.RawDetection d : detections) {
System.out.printf(
"Class %d txnc=%.1f tync=%.1f ta=%.2f%n",
d.classId, d.txnc, d.tync, d.ta
);
// Bounding box corners (in pixels)
// corner0 = top-left, corner1 = top-right
// corner2 = bottom-right, corner3 = bottom-left
System.out.printf(
" Corners: (%.0f,%.0f) (%.0f,%.0f) (%.0f,%.0f) (%.0f,%.0f)%n",
d.corner0_X, d.corner0_Y,
d.corner1_X, d.corner1_Y,
d.corner2_X, d.corner2_Y,
d.corner3_X, d.corner3_Y
);
}
Each RawDetection contains:| Field | Type | Description |
|---|
classId | int | Numeric class ID |
txnc | double | Horizontal offset from principal pixel in degrees |
tync | double | Vertical offset from principal pixel in degrees |
ta | double | Target area as % of image |
corner0_X / corner0_Y | double | Top-left corner coordinates |
corner1_X / corner1_Y | double | Top-right corner coordinates |
corner2_X / corner2_Y | double | Bottom-right corner coordinates |
corner3_X / corner3_Y | double | Bottom-left corner coordinates |
Full results via JSON
LimelightHelpers.LimelightResults results =
LimelightHelpers.getLatestResults("limelight");
for (LimelightHelpers.LimelightTarget_Detector d : results.targets_Detector) {
System.out.printf(
"Class: %s (ID %d) conf=%.2f ta=%.2f tx=%.1f ty=%.1f%n",
d.className, (int) d.classID, d.confidence,
d.ta, d.tx, d.ty
);
}
Each LimelightTarget_Detector contains:| Field | Description |
|---|
className | Human-readable class name |
classID | Numeric class ID |
confidence | Detection confidence (0–1) |
ta | Target area as % of image |
tx / ty | Angular offset from crosshair in degrees |
tx_pixels / ty_pixels | Offset in pixels |
tx_nocrosshair / ty_nocrosshair | Offset from principal pixel in degrees |