Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
spottercam Namespace Reference

Data Structures

struct  BasicDetection
 One accepted object in final still-image coordinates. More...
struct  BasicResult

Functions

uint32_t read_u32 (const uint8_t *data)
BasicResult decode (imx500::Span< const float > tensor, imx500::Span< const uint8_t > info, libcamera::Rectangle crop, libcamera::Size image)
BasicResult frame_result (const imx500::FrameView &frame)
 Interpret only the detector model's outputs from this retained exposure.
bool detector_ready (const imx500::FrameView &frame)
 Qualify startup from a valid detector head, including zero detections.
bool write_detections (const imx500::FrameView &frame, const char *filename)
 Publish detector results, never LOOM features or navigation evidence.

Variables

constexpr unsigned int sensor_width = imx500::sensor_width
constexpr unsigned int sensor_height = imx500::sensor_height
 Sensor-space height, separate from model and encoded-image dimensions.
constexpr unsigned int model_input_width = 320
constexpr unsigned int model_input_height = 320
 This detection head's input height; LOOM does not reuse its box semantics.
constexpr uint32_t expected_output_tensor_count = 4
constexpr uint32_t bbox_values_per_candidate = 4
constexpr uint32_t score_values_before_candidates = 4
constexpr uint32_t class_values_before_candidates = 5
constexpr uint32_t values_per_candidate_with_score_and_class = 6
constexpr uint32_t maximum_tensor_elements = IMX500_TENSOR_ELEMENT_LIMIT
constexpr uint32_t maximum_tensor_dimensions = IMX500_TENSOR_MAX_RANK
constexpr size_t tensor_info_header_size = IMX500_TENSOR_HEADER_BYTES
constexpr size_t tensor_count_offset
constexpr size_t first_tensor_record_offset
constexpr size_t tensor_record_size
constexpr size_t tensor_record_dimensions_offset
constexpr size_t tensor_record_dimension_bytes
constexpr size_t tensor_record_rank_offset
constexpr size_t tensor_record_length_offset
constexpr size_t tensor_info_size
constexpr size_t maximum_detections = 5
constexpr uint32_t object_class_index = 0
constexpr float object_confidence_threshold = 0.6f

Detailed Description

Internal implementation details documented here to make the camera and model contracts navigable.

Function Documentation

◆ decode()

BasicResult spottercam::decode ( imx500::Span< const float > tensor,
imx500::Span< const uint8_t > info,
libcamera::Rectangle crop,
libcamera::Size image )

Validate the model's four output tensors and project object boxes into the JPEG.

Parameters
tensorInterleaved boxes followed by scores, classes, and the detection count.
infoDriver CnnOutputTensorInfo bytes for this same camera request.
cropSensor crop reported in that request's ScalerCrop metadata.
imageConfigured still-stream dimensions.
Returns
Invalid by default; valid with zero or more boxes only after full validation.

This is intentionally model-specific. Raw neural arrays cannot be treated as boxes until shape, integral count and coordinate assumptions hold.

Definition at line 146 of file spotter_cam.cpp.

◆ detector_ready()

bool spottercam::detector_ready ( const imx500::FrameView & frame)

Qualify startup from a valid detector head, including zero detections.

Parameters
frameRetained exposure supplied by the neutral camera worker.
Returns
True when this model's decoder contract holds; not necessarily a hit.

Definition at line 252 of file spotter_cam.cpp.

◆ frame_result()

BasicResult spottercam::frame_result ( const imx500::FrameView & frame)

Interpret only the detector model's outputs from this retained exposure.

Parameters
frameBorrowed same-exposure tensors, crop and configured image size.
Returns
Invalid without crop evidence, otherwise the validated detector result.

A guessed full-sensor crop could put correct boxes in the wrong JPEG position, so missing geometry is a failed analysis rather than a default.

Definition at line 241 of file spotter_cam.cpp.

◆ read_u32()

uint32_t spottercam::read_u32 ( const uint8_t * data)

Decode one little-endian 32-bit integer from the driver's tensor-info byte array.

Parameters
dataAt least four readable bytes.
Returns
The unsigned value represented by data[0..3].

Definition at line 130 of file spotter_cam.cpp.

◆ write_detections()

bool spottercam::write_detections ( const imx500::FrameView & frame,
const char * filename )

Publish detector results, never LOOM features or navigation evidence.

Parameters
frameBorrowed exposure whose image/tensor identity is retained by a lease.
filenameNew analysis destination selected by the camera publication owner.
Returns
True after exclusive-create, flush, sync and close; false retains no partial output.

Readiness can describe an earlier warm-up frame. Decode this frame again rather than reusing a previous result for newly captured pixels.

Definition at line 263 of file spotter_cam.cpp.

Variable Documentation

◆ bbox_values_per_candidate

uint32_t spottercam::bbox_values_per_candidate = 4
constexpr

Left/top/right/bottom values in each candidate.

Definition at line 66 of file spotter_cam.cpp.

◆ class_values_before_candidates

uint32_t spottercam::class_values_before_candidates = 5
constexpr

Classes follow coordinates and scores.

Definition at line 68 of file spotter_cam.cpp.

◆ expected_output_tensor_count

uint32_t spottercam::expected_output_tensor_count = 4
constexpr

The model emits boxes, scores, classes, and a detection count in this order.

Definition at line 65 of file spotter_cam.cpp.

◆ first_tensor_record_offset

size_t spottercam::first_tensor_record_offset
constexpr
Initial value:
=
#define IMX500_TENSOR_FIRST_RECORD_OFFSET
First record starts after the count, keeping offset arithmetic in one place.

First record follows count.

Definition at line 81 of file spotter_cam.cpp.

◆ maximum_detections

size_t spottercam::maximum_detections = 5
constexpr

Current single-class model contract: class zero, confidence 0.6, at most five boxes.

Definition at line 99 of file spotter_cam.cpp.

◆ maximum_tensor_dimensions

uint32_t spottercam::maximum_tensor_dimensions = IMX500_TENSOR_MAX_RANK
constexpr

Maximum tensor rank documented by libcamera's Raspberry Pi IMX500 controls.

Definition at line 75 of file spotter_cam.cpp.

◆ maximum_tensor_elements

uint32_t spottercam::maximum_tensor_elements = IMX500_TENSOR_ELEMENT_LIMIT
constexpr

Maximum candidate count permitted by the model's fixed tensor scratch bound.

Definition at line 72 of file spotter_cam.cpp.

◆ model_input_height

unsigned int spottercam::model_input_height = 320
constexpr

This detection head's input height; LOOM does not reuse its box semantics.

Definition at line 62 of file spotter_cam.cpp.

◆ model_input_width

unsigned int spottercam::model_input_width = 320
constexpr

Input dimensions of the object RPK's absolute-coordinate detection head.

Definition at line 60 of file spotter_cam.cpp.

◆ object_class_index

uint32_t spottercam::object_class_index = 0
constexpr

Class selected by this detector's current model policy.

Definition at line 100 of file spotter_cam.cpp.

◆ object_confidence_threshold

float spottercam::object_confidence_threshold = 0.6f
constexpr

Reject low-confidence boxes without invalidating the whole head.

Definition at line 101 of file spotter_cam.cpp.

◆ score_values_before_candidates

uint32_t spottercam::score_values_before_candidates = 4
constexpr

Scores follow all box coordinate values.

Definition at line 67 of file spotter_cam.cpp.

◆ sensor_height

unsigned int spottercam::sensor_height = imx500::sensor_height
constexpr

Sensor-space height, separate from model and encoded-image dimensions.

Definition at line 58 of file spotter_cam.cpp.

◆ sensor_width

unsigned int spottercam::sensor_width = imx500::sensor_width
constexpr

Physical IMX500 pixel-array dimensions expected by the model's coordinate transform.

Definition at line 56 of file spotter_cam.cpp.

◆ tensor_count_offset

size_t spottercam::tensor_count_offset
constexpr
Initial value:
=
#define IMX500_TENSOR_COUNT_OFFSET
Little-endian 32-bit tensor count starts after the fixed header.

Four-byte tensor count follows the header.

Definition at line 79 of file spotter_cam.cpp.

◆ tensor_info_header_size

size_t spottercam::tensor_info_header_size = IMX500_TENSOR_HEADER_BYTES
constexpr

Metadata layout: fixed header, tensor count, then fixed-size tensor records.

Definition at line 78 of file spotter_cam.cpp.

◆ tensor_info_size

size_t spottercam::tensor_info_size
constexpr
Initial value:
=
#define IMX500_TENSOR_INFO_BYTES
Full accessible metadata required before following record offsets.

Full IMX500 metadata structure size (16 records, each with up to 16 dimensions).

Definition at line 95 of file spotter_cam.cpp.

◆ tensor_record_dimension_bytes

size_t spottercam::tensor_record_dimension_bytes
constexpr
Initial value:
=
#define IMX500_TENSOR_DIMENSION_BYTES
Each extent is a little-endian unsigned 16-bit value.

Each shape entry is an unsigned 16-bit value.

Definition at line 87 of file spotter_cam.cpp.

◆ tensor_record_dimensions_offset

size_t spottercam::tensor_record_dimensions_offset
constexpr
Initial value:
=
#define IMX500_TENSOR_DIMENSIONS_OFFSET
First shape extent follows the two 32-bit fields.

Length and rank occupy the first eight bytes.

Definition at line 85 of file spotter_cam.cpp.

◆ tensor_record_length_offset

size_t spottercam::tensor_record_length_offset
constexpr
Initial value:
=
#define IMX500_TENSOR_LENGTH_OFFSET
Element count offset within a record, distinct from its byte length.

Element count starts each record.

Definition at line 91 of file spotter_cam.cpp.

◆ tensor_record_rank_offset

size_t spottercam::tensor_record_rank_offset
constexpr
Initial value:
=
#define IMX500_TENSOR_RANK_OFFSET
Shape rank offset within a record.

Rank follows the four-byte element count.

Definition at line 89 of file spotter_cam.cpp.

◆ tensor_record_size

size_t spottercam::tensor_record_size
constexpr
Initial value:
=
#define IMX500_TENSOR_RECORD_BYTES
One record contains length, rank and sixteen 16-bit shape extents.

Fixed fields followed by sixteen 16-bit dimensions.

Definition at line 83 of file spotter_cam.cpp.

◆ values_per_candidate_with_score_and_class

uint32_t spottercam::values_per_candidate_with_score_and_class = 6
constexpr

Count follows the three candidate arrays.

Definition at line 69 of file spotter_cam.cpp.