IVisionFrames — the V5 AI Vision camera read a FRAME at a time.
This header declares 9 types (59 members), 5 free functions, and 5 constants.
Extracted from include/shulib/hal/vision_frames.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.
kMaxVisionDetections— constantkMaxColourDescriptors— constantkMaxVisionClassNames— constantkVisionImageWidthPx— constantkVisionImageHeightPx— constantenum class DetectionKindstruct Detectionenum class FrameStatusenum class ModelCheckstruct VisionFramestruct ColourDescriptorcolourDescriptorProblem— free functionstruct AiVisionSettingsaiVisionSettingsProblem— free functionsameVisionText— free functionsameAiVisionSettings— free functionstruct CameraStatuscameraStatusWords— free functionclass IVisionFrames
inline constexpr std::size_t kMaxVisionDetections = 24The camera's most detections per read (AIVISION_MAX_OBJECT_COUNT, the vendored ai_vision.h :33 — restated so this header stays PROS-free; hal/pros/ai_vision.hpp static_asserts the two agree).
constant, declared at include/shulib/hal/vision_frames.hpp:48.
inline constexpr std::uint8_t kMaxColourDescriptors = 7Colour descriptor ids run 1..7 (ai_vision.h :86).
constant, declared at include/shulib/hal/vision_frames.hpp:50.
inline constexpr std::uint8_t kMaxVisionClassNames = 20The most class names a camera's model can name (AIVISION_MAX_CLASSNAME_COUNT, ai_vision.h :34).
constant, declared at include/shulib/hal/vision_frames.hpp:52.
inline constexpr int kVisionImageWidthPx = 320The camera's report width, in pixels (api.vex.com: 320 x 240; A4 register HA-193).
constant, declared at include/shulib/hal/vision_frames.hpp:54.
inline constexpr int kVisionImageHeightPx = 240The camera's report height, in pixels (A4 register HA-193).
constant, declared at include/shulib/hal/vision_frames.hpp:56.
enum class DetectionKind : std::uint8_tWhat a detection IS. OURS, not PROS's bit flags — the adapter maps each. No Tag: VIS1 turns tag detection OFF, and a tag that arrives anyway is counted in VisionFrame::skipped, never passed on.
enum class, declared at include/shulib/hal/vision_frames.hpp:60.
Colour = 1a colour descriptor's blob: id is the descriptor, 1..7 — one the settings wrote
enumerator, declared at include/shulib/hal/vision_frames.hpp:61.
Code = 2a colour code's merged blob, id 1..5 (VIS1 writes none; its adapter withholds each)
enumerator, declared at include/shulib/hal/vision_frames.hpp:62.
Object = 3the AI model's element: id is its class (meaningful only once ModelCheck::Matches)
enumerator, declared at include/shulib/hal/vision_frames.hpp:63.
struct DetectionOne detection, copied OUT of the camera's packed record, in IMAGE pixels: +x right, +y DOWN, (0,0) the top-left corner; the box's LEFT and TOP edges plus its size (ai_vision.h :129-130's "left edge" / "top edge" — A4 register HA-193).
struct, declared at include/shulib/hal/vision_frames.hpp:69.
DetectionKind kind = DetectionKind::Colourwhat it is
field, declared at include/shulib/hal/vision_frames.hpp:70.
std::uint8_t id = 0descriptor 1..7 / code 1..5 / model class 0..
field, declared at include/shulib/hal/vision_frames.hpp:71.
std::int16_t left = 0px from the image's left edge
field, declared at include/shulib/hal/vision_frames.hpp:72.
std::int16_t top = 0px from the image's top edge
field, declared at include/shulib/hal/vision_frames.hpp:73.
std::int16_t width = 0px
field, declared at include/shulib/hal/vision_frames.hpp:74.
std::int16_t height = 0px
field, declared at include/shulib/hal/vision_frames.hpp:75.
std::int16_t angleTenths = 0Colour/Code only: the blob's angle, tenths of a degree
field, declared at include/shulib/hal/vision_frames.hpp:76.
std::int32_t score = -1Object only: the raw score, 0..65535 (its scale: HA-198); -1 otherwise
field, declared at include/shulib/hal/vision_frames.hpp:77.
[[nodiscard]] constexpr bool clipped(int marginPx = 1) const noexceptTrue when the box comes within marginPx of an edge of the image (inclusive at both ends) — part of the thing may be outside the picture, so its size says nothing about its distance.
function, declared at include/shulib/hal/vision_frames.hpp:81.
enum class FrameStatus : std::uint8_tHow a read went. ONLY Ok is evidence of anything.
enum class, declared at include/shulib/hal/vision_frames.hpp:89.
NotRead = 0default-constructed: no read happened
enumerator, declared at include/shulib/hal/vision_frames.hpp:90.
Okthe count and every object read answered with a valid type
enumerator, declared at include/shulib/hal/vision_frames.hpp:91.
ReadFaulta read failed — the count (PROS_ERR), or a read-back the adapter's once-a-second check could not make: NO detections — never a held frame
enumerator, declared at include/shulib/hal/vision_frames.hpp:92.
PartialFaultthe count answered, an object read did not (a torn read, HA-195): not evidence
enumerator, declared at include/shulib/hal/vision_frames.hpp:94.
NotConfiguredthe adapter's set-up has not succeeded yet (or was lost): nothing was read
enumerator, declared at include/shulib/hal/vision_frames.hpp:95.
enum class ModelCheck : std::uint8_tWhether the camera's AI model is the one the robot file expects, checked BY NAME (the camera's own class-name table, ai_vision.h :371-389) — a model class id means nothing until this says Matches: class 3 is yellowPin in VEX's Override model and blueRing in its Classroom model (A4 register HA-197). Object detections are passed on ONLY while it reads Matches.
enum class, declared at include/shulib/hal/vision_frames.hpp:102.
NotAsked = 0objects are off, or no read has asked yet
enumerator, declared at include/shulib/hal/vision_frames.hpp:103.
Matchesevery expected class name read back, in order
enumerator, declared at include/shulib/hal/vision_frames.hpp:104.
Differentthe camera names another table (another model is selected on it), or nothing
enumerator, declared at include/shulib/hal/vision_frames.hpp:105.
Unreadablethe class-name read failed (PROS_ERR) — the camera may still be booting
enumerator, declared at include/shulib/hal/vision_frames.hpp:106.
struct VisionFrameOne READ of the camera — not a camera frame: the camera may update between the count read and the object reads (HA-195). What ONE poll saw, and when the poll finished.
struct, declared at include/shulib/hal/vision_frames.hpp:111.
FrameStatus status = FrameStatus::NotReadonly Ok is evidence
field, declared at include/shulib/hal/vision_frames.hpp:112.
units::Time readAt{}The clock when the read COMPLETED — not the exposure: the IMAGE is older by an UNMEASURED age (A4 register HA-192; a consumer pairing a frame with a pose widens the pose's bound for it — vision::boundAtImage).
field, declared at include/shulib/hal/vision_frames.hpp:116.
std::uint32_t readSeq = 0the adapter's poll count — NOT a camera frame number (HA-192)
field, declared at include/shulib/hal/vision_frames.hpp:117.
std::int32_t reportedCount = 0what the camera said it holds (it may say more than 24)
field, declared at include/shulib/hal/vision_frames.hpp:118.
bool truncated = falsePOSSIBLY FULL: the camera reported kMaxVisionDetections OR MORE, so detections may exist that were never sent (a read of exactly 24 cannot show that the 25th was not the one that mattered — whether a camera can report more than 24 is A4 register HA-198's question; the design does not depend on the answer). Never evidence of absence.
field, declared at include/shulib/hal/vision_frames.hpp:123.
std::uint8_t count = 0valid entries in detections
field, declared at include/shulib/hal/vision_frames.hpp:124.
std::uint8_t skipped = 0object reads with no valid type, or a TAG (tags are off)
field, declared at include/shulib/hal/vision_frames.hpp:125.
ModelCheck model = ModelCheck::NotAskedthe AI model's check at this read
field, declared at include/shulib/hal/vision_frames.hpp:126.
std::uint8_t objectsWithheld = 0Object detections NOT passed on (the model not Matches, or an id past the table)
field, declared at include/shulib/hal/vision_frames.hpp:127.
std::uint8_t coloursWithheld = 0Colour and Code detections NOT passed on: a descriptor this program did not write (a slot another program left set), or any code (VIS1 writes none).
field, declared at include/shulib/hal/vision_frames.hpp:130.
Detection detections[kMaxVisionDetections]{}[0, count) are valid; their order is UNVERIFIED (HA-198)
field, declared at include/shulib/hal/vision_frames.hpp:131.
[[nodiscard]] constexpr bool usable() const noexceptTrue only when this read is EVIDENCE (status Ok).
function, declared at include/shulib/hal/vision_frames.hpp:134.
struct ColourDescriptorOne colour descriptor as the camera takes it (ai_vision.h :85-92): an id 1..7, an RGB, a hue tolerance in degrees (1..40) and a saturation tolerance (0.1..1). EVERY FIELD IS A MEASURED FACT the team types (from VEXcode's AI Vision Utility); the defaults are UNSET and refuse.
struct, declared at include/shulib/hal/vision_frames.hpp:140.
std::uint8_t id = 01..7; 0 = UNSET
field, declared at include/shulib/hal/vision_frames.hpp:141.
std::uint8_t red = 00..255
field, declared at include/shulib/hal/vision_frames.hpp:142.
std::uint8_t green = 00..255
field, declared at include/shulib/hal/vision_frames.hpp:143.
std::uint8_t blue = 00..255
field, declared at include/shulib/hal/vision_frames.hpp:144.
float hueRange = 0.0Fdegrees, 1..40; 0 = UNSET
field, declared at include/shulib/hal/vision_frames.hpp:145.
float saturationRange = 0.0F0.1..1; 0 = UNSET
field, declared at include/shulib/hal/vision_frames.hpp:146.
const char* name = ""the team's word for it ("toggle red"), for every log line
field, declared at include/shulib/hal/vision_frames.hpp:147.
const char* provenance = ""who measured it, how, when, under what light — required
field, declared at include/shulib/hal/vision_frames.hpp:148.
[[nodiscard]] constexpr const char* colourDescriptorProblem(const ColourDescriptor& c) noexceptWhy c is not acceptable, or nullptr. An all-zero descriptor (id, hue and saturation all 0) is UNSET and refuses; otherwise an id outside 1..7, a hue outside 1..40 or a saturation outside 0.1..1 (each inclusive, NaN refused), a null name, or a missing provenance each refuses by name. Nothing inside the vendored ranges is refused.
free function, declared at include/shulib/hal/vision_frames.hpp:155.
struct AiVisionSettingsWhat the adapter writes to the camera: EXACTLY these modes — TAGS always OFF (VIS1 reads no tags, and Bench Tests station 12 leaves tags ON; a tag would take one of the 24 slots) — and these descriptors.
struct, declared at include/shulib/hal/vision_frames.hpp:180.
ColourDescriptor colours[kMaxColourDescriptors]{}[0, colourCount) are written
field, declared at include/shulib/hal/vision_frames.hpp:181.
std::uint8_t colourCount = 00 => COLORS off
field, declared at include/shulib/hal/vision_frames.hpp:182.
bool objects = falsethe AI model's game elements (ai_vision.h :73)
field, declared at include/shulib/hal/vision_frames.hpp:183.
const char* const* expectedClasses = nullptrWith objects: the class names the camera's model must report, in id order (the season's table — vision/override_elements.hpp's kOverrideClassNames). Required: an object id is opaque without it (ModelCheck). BORROWED: the array and its strings must outlive every adapter built from it (a constexpr table does).
field, declared at include/shulib/hal/vision_frames.hpp:188.
std::uint8_t expectedClassCount = 0entries in expectedClasses, 1..kMaxVisionClassNames
field, declared at include/shulib/hal/vision_frames.hpp:189.
bool colourMerge = falseCOLOR_MERGE (ai_vision.h :74)
field, declared at include/shulib/hal/vision_frames.hpp:190.
[[nodiscard]] constexpr const char* aiVisionSettingsProblem(const AiVisionSettings& s) noexceptThe first problem with a settings block, or nullptr: more than 7 colours; a colour's own problem; two colours on one id (the camera silently keeps the second write, ai_vision.h :340); COLOR_MERGE with no colours; NOTHING turned on (a camera configured to see nothing is a wiring mistake, not a choice); objects on with no class table, an empty one, more than 20 names, or a null or empty name.
free function, declared at include/shulib/hal/vision_frames.hpp:197.
[[nodiscard]] constexpr bool sameVisionText(const char* a, const char* b) noexceptTwo C strings equal by CONTENT (two null pointers are equal; a null and a non-null are not).
free function, declared at include/shulib/hal/vision_frames.hpp:234.
[[nodiscard]] constexpr bool sameAiVisionSettings(const AiVisionSettings& a, const AiVisionSettings& b) noexceptWhether two settings blocks would write the SAME thing to a camera: field by field, every string by content, the colours and class names only up to their counts (entries past a count are never written). The device provider serves a second request for a camera only with settings equal to the first's — two owners disagreeing about one camera is refused (hal/pros/device_provider.hpp).
free function, declared at include/shulib/hal/vision_frames.hpp:251.
struct CameraStatusWhat the camera's adapter knows about its own set-up and AI model, WITHOUT touching the device. The two strings are the adapter's own words, "" when there is nothing to say; they live as long as the adapter and change only on a read() (single-task).
struct, declared at include/shulib/hal/vision_frames.hpp:280.
bool configured = falsethe set-up was written AND read back
field, declared at include/shulib/hal/vision_frames.hpp:281.
const char* setupProblem = ""why the last set-up failed or was re-done ("" when it holds)
field, declared at include/shulib/hal/vision_frames.hpp:282.
ModelCheck model = ModelCheck::NotAskedthe AI model's check (NotAsked: objects off)
field, declared at include/shulib/hal/vision_frames.hpp:283.
const char* modelProblem = ""e.g. "class 0 is 'blueBall', the robot file expects 'redBluePin'"
field, declared at include/shulib/hal/vision_frames.hpp:284.
[[nodiscard]] constexpr const char* cameraStatusWords(const CameraStatus& s) noexceptThe camera's state in a few ASCII words for a boot line or a bench page (the brain's screen turns non-ASCII into '?'): "NOT set up", "set up, objects off", "set up, model OK", "set up, model check pending" (the names did not read — re-asked once a second), "set up, model DIFFERENT". A caller that needs the reason prints setupProblem / modelProblem after it.
free function, declared at include/shulib/hal/vision_frames.hpp:291.
class IVisionFramesThe camera, read a frame at a time. read() HITS THE DEVICE (one count read, then one read per detection; once a second, the PROS adapter's check of its settings and model; and, after a lost setting or a failed read, at most every half second, its set-up written again — A4 register HA-203), so it is not const, and reading at the rate a consumer needs is the consumer's job. Single-task by contract, like every device here.
class, declared at include/shulib/hal/vision_frames.hpp:309.
virtual ~IVisionFrames() = defaultPolymorphic base: delete-through-base is well-defined; the provider owns every camera.
function, declared at include/shulib/hal/vision_frames.hpp:312.
IVisionFrames() = defaultPolymorphic base: delete-through-base is well-defined; the provider owns every camera. Default-constructible: the base has no state.
function, declared at include/shulib/hal/vision_frames.hpp:314.
IVisionFrames(const IVisionFrames&) = defaultPolymorphic base: delete-through-base is well-defined; the provider owns every camera. Default-constructible: the base has no state. Copyable at the base (stateless); an adapter decides for itself.
function, declared at include/shulib/hal/vision_frames.hpp:316.
IVisionFrames(IVisionFrames&&) = defaultPolymorphic base: delete-through-base is well-defined; the provider owns every camera. Default-constructible: the base has no state. Copyable at the base (stateless); an adapter decides for itself. Movable, same reasoning.
function, declared at include/shulib/hal/vision_frames.hpp:318.
IVisionFrames& operator=(const IVisionFrames&) = defaultPolymorphic base: delete-through-base is well-defined; the provider owns every camera. Default-constructible: the base has no state. Copyable at the base (stateless); an adapter decides for itself. Movable, same reasoning. Copy-assignable, same reasoning.
function, declared at include/shulib/hal/vision_frames.hpp:320.
IVisionFrames& operator=(IVisionFrames&&) = defaultPolymorphic base: delete-through-base is well-defined; the provider owns every camera. Default-constructible: the base has no state. Copyable at the base (stateless); an adapter decides for itself. Movable, same reasoning. Copy-assignable, same reasoning. Move-assignable, same reasoning.
function, declared at include/shulib/hal/vision_frames.hpp:322.
[[nodiscard]] virtual VisionFrame read() noexcept = 0Read the camera NOW (A4 register HA-203: one call per detection, plus the count; once a second the PROS adapter's check, up to 28 more; and a set-up written again, up to 36 more). A failed read is a frame whose status says so, with NO detections — never the last good frame.
function, declared at include/shulib/hal/vision_frames.hpp:327.
[[nodiscard]] virtual CameraStatus status() const noexcept = 0The adapter's set-up and model check as it last found them — never touches the device.
function, declared at include/shulib/hal/vision_frames.hpp:329.
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 — 36 lines
IVisionFrames — the V5 AI Vision camera read a FRAME at a time (chunk VIS1-A1, 2026-10-18).
── An F4-ADDITIVE SIBLING of the frozen hal::IVision ───────────────────────────────
hal/vision.hpp is untouched, byte for byte (F4, LOCKED 2026-06-19). This seam sits beside it, exactly
as IDigitalOut (F11), IController (F13), IDigitalIn (F14) and IReadFaults (MECH-A1) were added beside
the frozen set. It is NOT FROZEN (the Freeze Register says so out loud, row F15).
── Why a sibling and not IVision ───────────────────────────────────────────────────
IVision yields a class id, a bearing and a confidence (hal/vision.hpp's ObjectObservation). It has no
detection TYPE — a colour descriptor 1 and a model class 1 are the same `classId` —, no BOX (so no
size, no elevation, no range) and no TIME. And the PROS AI Vision API has NO frame counter and NO
timestamp (the vendored include/pros/ai_vision.h, read whole): freshness can only be TIME-based. So a
frame carries the time its READ completed, stamped from the run's IClock, and a read count that
counts the ADAPTER's polls — never camera frames (A4 register HA-192). The image itself is OLDER than
that read by an age nobody has measured (HA-192 again): a consumer that pairs a frame with a pose
widens the pose's bound for it (vision::boundAtImage).
── A FAILED READ IS A FRAME THAT SAYS SO, WITH NO DETECTIONS ──────────────────────
Never the last good frame held. The F4 sensor adapters answer a PROS_ERR with their last good value
(MECH-A1's read-fault channel exists because of it); a frame cannot, because a held frame would read
as a fresh "nothing changed". Only `FrameStatus::Ok` is evidence of anything.
── What the adapter writes, as data ────────────────────────────────────────────────
AiVisionSettings is the robot file's camera block's adapter half (config/camera_config.hpp carries
it): the colour descriptors the team measured with VEXcode's AI Vision Utility, whether the AI model's
OBJECTS are on, and the class names the model must report BY NAME before an object id means anything
(ModelCheck; HA-197). Its refusals are named — an all-zero descriptor is UNSET, never a colour.
── status(): the set-up and the model check, through the SEAM ──────────────────────
The Robot's boot line and a bench page report whether the camera was set up and whether its AI model
matched — and the builder never reads a frame and must never downcast to the PROS adapter. So the
seam carries `status()`, which touches nothing (VIS1's re-check T2).
Allocation-free (a fixed 24-entry array — AIVISION_MAX_OBJECT_COUNT, ai_vision.h :33), PROS-free,
sim-free. Single-task by contract, like every device here.