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
spotter_cam.cpp File Reference

Object-model decoder, detection sidecar writer and detector entry point. More...

#include <algorithm>
#include <array>
#include <cerrno>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <chrono>
#include <poll.h>
#include <sys/stat.h>
#include <unistd.h>
#include "version.h"
#include "inference_worker.h"
#include "spotter_targets.h"
#include "camera_profile.h"
#include "imx500_camera.hpp"
#include "imx500_tensor.h"
#include "inference_capture.hpp"
Include dependency graph for spotter_cam.cpp:

Go to the source code of this file.

Data Structures

struct  spottercam::BasicDetection
 One accepted object in final still-image coordinates. More...
struct  spottercam::BasicResult
struct  TargetTransaction
 Publish a proposed slot and commit only after the transport confirms it. More...

Namespaces

namespace  spottercam

Functions

uint32_t spottercam::read_u32 (const uint8_t *data)
BasicResult spottercam::decode (imx500::Span< const float > tensor, imx500::Span< const uint8_t > info, libcamera::Rectangle crop, libcamera::Size image)
BasicResult spottercam::frame_result (const imx500::FrameView &frame)
 Interpret only the detector model's outputs from this retained exposure.
bool spottercam::detector_ready (const imx500::FrameView &frame)
 Qualify startup from a valid detector head, including zero detections.
bool spottercam::write_detections (const imx500::FrameView &frame, const char *filename)
 Publish detector results, never LOOM features or navigation evidence.
static int simulation_mode (int argc, char **argv)
 Select simulation input using the common bounded settings parser.
static int project_ground (int argc, char **argv)
 Project one delivered-image point with the shared camera/coverage geometry.
static int target_line (char *line, size_t capacity, bool acknowledgement)
 Read one bounded printable protocol line.
static bool publish_target (void *context, unsigned slot, const spotter_target *target)
 Propose a target update and require its matching acknowledgement.
static int target_server ()
 Run a bounded, model-independent geographic target stream.
int main (int argc, char **argv)
 Select detector-specific policy, then run neutral capture mechanics.

Variables

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

Detailed Description

Object-model decoder, detection sidecar writer and detector entry point.

Camera/DMA/JPEG ownership belongs to imx500_camera.cpp. This application interprets retained frame metadata only as object boxes; it contains no LOOM feature processing, reference matching or waypoint policy. A structurally valid empty detection result is useful evidence and differs from missing or malformed inference; keep that distinction when extending the model contract.

Definition in file spotter_cam.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Select detector-specific policy, then run neutral capture mechanics.

Parameters
argcCommand-line token count.
argvVersion or probe/capture/serve arguments.
Returns
Zero on success, two for syntax errors, one for worker failure.

The explicit .objects.ini callback keeps object interpretation out of the shared camera and out of LOOM's independently linked executable.

Definition at line 763 of file spotter_cam.cpp.

◆ project_ground()

int project_ground ( int argc,
char ** argv )
static

Project one delivered-image point with the shared camera/coverage geometry.

Emits east/north offsets, not a new navigation command. The caller supplies the observed pose and retains ownership of the geographic datum.

Definition at line 622 of file spotter_cam.cpp.

◆ publish_target()

bool publish_target ( void * context,
unsigned slot,
const spotter_target * target )
static

Propose a target update and require its matching acknowledgement.

Parameters
[in,out]contextActive TargetTransaction holding the correlation sequence.
slotProposed target slot.
targetBorrowed ranked target observation.
Returns
True only if the peer acknowledged this transaction.

Flush before reading the reply. Distinguish a missing or malformed line from a complete nonmatching response so the caller can detect channel failure.

Definition at line 699 of file spotter_cam.cpp.

◆ simulation_mode()

int simulation_mode ( int argc,
char ** argv )
static

Select simulation input using the common bounded settings parser.

Only an absent model permits fabricated spotting. A present ONNX file is qualified by the normal shared analysis worker, never by this probe.

Definition at line 553 of file spotter_cam.cpp.

◆ target_line()

int target_line ( char * line,
size_t capacity,
bool acknowledgement )
static

Read one bounded printable protocol line.

Parameters
[out]lineBuffer for the line, newline and terminator.
capacityTotal buffer bytes.
acknowledgementTrue to impose a deadline on the read.
Returns
One for a complete line, zero for clean EOF, or -1 on failure.

Keep one deadline across all bytes of an acknowledgement so a partially responsive peer cannot prolong a pending transaction indefinitely.

Definition at line 669 of file spotter_cam.cpp.

◆ target_server()

int target_server ( )
static

Run a bounded, model-independent geographic target stream.

Returns
Zero on orderly EOF, two for malformed/out-of-order input, one for I/O failure.

OBS sequence latitude longitude ellipsoid_mm score proposes one observation. MOVE awaits ACK sequence; OK commits, SKIP retains existing slots. Restarting the worker clears all five slots without moving any FC waypoint.

Definition at line 718 of file spotter_cam.cpp.