← Back to Home · Back to Programming

Programming · Vision

Vision that works on the field

Camera setup, OpenCV basics, AprilTags overview, and how to survive common vision failures.

What this is

  • Quick path to get a camera feed and simple pipelines running.
  • Overview of AprilTags usage for pose/ID.
  • Checks to keep vision stable under match lighting.

When you need it

  • First time adding a webcam or pipeline to FTC code.
  • Detection drops under bright or dim venues.
  • AprilTags pose is noisy or IDs flicker.

How it works

  • Camera: use UVC webcams; set resolution modest (e.g., 640x480) to keep FPS.
  • OpenCV: create a pipeline class; process frames, output telemetry; keep operations lightweight.
  • AprilTags: calibrate camera if using pose; set correct tag size and FX/FY/CX/CY; stabilize by averaging a few frames.
  • Lighting: prefer auto exposure off if unstable; clamp brightness with simple thresholds.

Common mistakes

  • Running high resolution → low FPS and timeouts.
  • No camera calibration for pose → wrong distances/angles.
  • Blocking pipelines (heavy loops) that starve OpMode.
  • Hardcoded tag size/focal lengths from sample that don’t match your setup.

How to test it

  • Print FPS and detection latency in telemetry.
  • Move tag or target slowly; ensure IDs stay stable and pose doesn’t jump wildly.
  • Test under venue-like lighting; adjust exposure/white balance if needed.
  • Check CPU load; keep control loop responsive while vision runs.

Related problems

  • Pipeline crashes → add null checks; guard empty detections; keep processing lightweight.
  • Pose noise → average a few frames; ensure correct camera intrinsics and tag size.
  • FPS drops mid-match → reduce resolution or complexity; avoid heavy allocations per frame.