CameraFeed — ONE read of the camera per period, handed to every consumer.
This header declares 3 types (15 members) and 1 free function.
Extracted from include/shulib/vision/camera_feed.hpp — this page is that header's documentation, reformatted, so it cannot disagree with the code. Prose about how to think about the API lives in How it works; worked recipes live in Recipes; this page is the complete, mechanical list of what exists.
struct CameraFeedConfigcameraFeedConfigProblem— free functionstruct CameraFeedStatsclass CameraFeed
struct CameraFeedConfigThe feed's one number — the TEAM's. 0 = UNSET, and refused (no library default).
struct, declared at include/shulib/vision/camera_feed.hpp:39.
double minReadPeriodSeconds = 0.0Read at most this often, seconds — e.g. 0.033 (VEX's ~30 frames a second, A4 register HA-192).
field, declared at include/shulib/vision/camera_feed.hpp:41.
[[nodiscard]] constexpr const char* cameraFeedConfigProblem(const CameraFeedConfig& c) noexceptThe first problem with a feed config, or nullptr: a period that is UNSET, zero, negative, NaN or infinite (an infinite one would read once and never again).
free function, declared at include/shulib/vision/camera_feed.hpp:46.
struct CameraFeedStatsWhat the feed has seen — for a bench page, and for A4 register HA-203's settle (the read's cost).
struct, declared at include/shulib/vision/camera_feed.hpp:54.
std::uint32_t reads = 0reads made
field, declared at include/shulib/vision/camera_feed.hpp:55.
std::uint32_t usable = 0of them, status Ok
field, declared at include/shulib/vision/camera_feed.hpp:56.
std::uint32_t readFaults = 0of them, status ReadFault
field, declared at include/shulib/vision/camera_feed.hpp:57.
std::uint32_t partialFaults = 0of them, status PartialFault (a torn read)
field, declared at include/shulib/vision/camera_feed.hpp:58.
std::uint32_t notConfigured = 0of them, status NotConfigured
field, declared at include/shulib/vision/camera_feed.hpp:59.
std::uint32_t truncated = 0usable reads that were POSSIBLY FULL (24 or more reported)
field, declared at include/shulib/vision/camera_feed.hpp:60.
std::uint32_t objectsWithheld = 0Object detections the adapter withheld, summed over the reads
field, declared at include/shulib/vision/camera_feed.hpp:61.
std::uint32_t coloursWithheld = 0Colour and Code detections the adapter withheld, summed
field, declared at include/shulib/vision/camera_feed.hpp:62.
double lastReadSeconds = 0.0how long the last read took: the clock after it less before it
field, declared at include/shulib/vision/camera_feed.hpp:63.
double slowestReadSeconds = 0.0the longest read so far, seconds
field, declared at include/shulib/vision/camera_feed.hpp:64.
class CameraFeedOne camera read per period for every consumer (header). Holds references: the camera and the clock must outlive the feed. PRECONDITION: cameraFeedConfigProblem(cfg) == nullptr (a consumer that builds one asks first and refuses to construct, naming it).
class, declared at include/shulib/vision/camera_feed.hpp:70.
CameraFeed(hal::IVisionFrames& camera, const hal::IClock& clock, const CameraFeedConfig& cfg) noexceptReads nothing until the first tick().
function, declared at include/shulib/vision/camera_feed.hpp:73.
bool tick()Read the camera if at least the period has passed since the last read BEGAN (the first call always reads); never more than one read per call. True when it read — latest() is then a new frame.
function, declared at include/shulib/vision/camera_feed.hpp:78.
[[nodiscard]] const hal::VisionFrame& latest() const noexceptThe latest READ — a fault frame included, never the last good one held; a default frame (status NotRead) before the first.
function, declared at include/shulib/vision/camera_feed.hpp:111.
[[nodiscard]] const CameraFeedStats& stats() const noexceptWhat the feed has seen.
function, declared at include/shulib/vision/camera_feed.hpp:113.
The header opens with the reasoning behind these shapes. It is reproduced here in full because a reference that only lists signatures teaches nobody why.
The header’s own reasoning — 27 lines
CameraFeed — ONE read of the camera per period, handed to every consumer (chunk VIS1-A2, 2026-11-03).
── Who reads the camera, and how often ─────────────────────────────────────────────
A read is one device call for the count and one per detection (up to 25), plus the adapter's own
checks (hal::IVisionFrames::read()), and the library is single-task by contract: every device here is
read from the caller's own loop, never from a task of the library's. So the program's loop — the
driver loop's per-tick hook, an auton step's wait — calls tick() once per ITS tick, and the feed reads
the camera only when at least `minReadPeriodSeconds` has passed since its last read BEGAN (never twice
in one call). Every consumer — the Toggle tracker, the piece finder, and later the automatic flip and
the drive to a piece — is handed the SAME frame through latest(): two consumers never cost two reads,
and none reads faster than the camera changes (VEX states about 30 frames a second — A4 register
HA-192 — so about 0.033 s is the natural floor; the period is the TEAM's number, and an UNSET one is
refused: no library default).
── latest() is the latest READ — never the last good one ───────────────────────────
A fault frame included: a frame held over a failed read would read as a fresh "nothing changed"
(hal/vision_frames.hpp). Only `FrameStatus::Ok` is evidence, and each consumer checks it.
── Every read is timed ─────────────────────────────────────────────────────────────
With the clock before and after it (on the robot that clock is pros::micros()-backed —
hal/pros/clock.hpp), so stats() carries the last and the slowest read's cost: the measurement
A4 register HA-203 (one read is cheap enough for the driver loop's tick) needs, from the loop the
read actually runs in.
No task, no allocation, PROS-free, sim-free; single-task, like every device here. NO HARDWARE CLAIM:
it has run against the host's fake camera and nothing else.