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
loomcam.c File Reference

Guarded retained-vector return processing and transactional T1 policy. More...

#include "camera_backend.h"
#include "loom_return.h"
#include "loom_features.h"
#include "../../src/inference_settings.h"
#include "../../src/inference_model.h"
#include "../../src/inference_jpeg.h"
#include "../../src/exifite.h"
#include "../../src/imx500_tensor.h"
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for loomcam.c:

Go to the source code of this file.

Data Structures

struct  loom_frame
 Borrowed per-invocation input; no member owns or acquires a camera. More...

Macros

#define LOOM_DECIMAL_RADIX   10
 The CLI accepts decimal photo numbers, never signed or truncated IDs.
#define LOOM_SELF_TEST_SEQUENCE   UINT32_C(1)
 Nonzero fixtures deliberately expose failure to clear previous state.
#define LOOM_SELF_TEST_LATITUDE   INT32_C(1)
 Nonzero latitude fixture checks that no-match clears stale evidence.
#define LOOM_SELF_TEST_SEQUENCE_OVERFLOW   "4294967296"
 First integer outside the accepted uint32_t correlation range.

Enumerations

enum  loom_cli_layout { LOOM_FIRST_OPTION_INDEX = 1 , LOOM_SINGLE_OPTION_ARGC = 2 }
 argv[0] is the program name; a sole flag gives two total arguments. More...
enum  { LOOM_CONFIRMATION_TIMEOUT_MS = 4000 }

Functions

static bool return_settings (const char *path, struct inference_settings *settings, struct loom_return_options *options)
 Reuse common path/INI policy without opening a model or camera.
static bool description_lookup (const struct exif_value *description, const char *key, char value[64], bool *found)
 Read one bounded observation field from an already-fetched EXIF description.
static bool description_field (const struct exif_value *description, const char *key, char value[64])
 Require a uniquely identified flight-description value.
static bool description_number (const struct exif_value *description, const char *key, double *number)
 Read a required finite numeric metadata field.
static bool description_optional_number (const struct exif_value *description, const char *key, double default_value, double *number)
 Read numeric metadata with a default for absence only.
static bool read_onnx_descriptor_identity (const struct inference_settings *settings, char graph[65], char descriptor[65])
 Read the graph and descriptor identities declared by the model metadata.
static uint64_t feature_u64 (const unsigned char *bytes)
 Decode an unsigned field from LOOM's little-endian record.
static bool run_onnx_in_memory (const struct inference_settings *settings, const struct loom_return_options *options, const char *image, uint64_t sequence, uint64_t timestamp_ns, unsigned char *record, size_t capacity, size_t *record_size)
 Generate bounded LOOM feature evidence for an existing JPEG.
static bool match_previous_photos (const struct loom_frame *frame, struct camera_point_result *point)
 Interpret retained same-photo neural vectors under the declared return contract.
static bool parse_sequence (const char *text, uint32_t *sequence)
 Parse a nonzero correlation sequence without truncation or signed input.
static int simulation_mode (int argc, char **argv)
 Describe whether PC imagery can run a selected ONNX graph.
static int return_line (char *line, size_t capacity, unsigned timeout_ms)
 Split one bounded ASCII command, rejecting binary/trailing/oversized input.
static int return_server (int argc, char **argv)
 Keep bounded T1 state separate from the waypoint transport transaction.
static int self_test (void)
 Hardware-free check that the empty matcher cannot manufacture a waypoint.
int main (int argc, char **argv)
 Parse one saved-photo request and emit exactly one correlated result line.

Detailed Description

Guarded retained-vector return processing and transactional T1 policy.

Declared model vectors, aligned observation metadata and configured HOME produce bounded point proposals from explicitly declared model vectors. Outbound references are archived; reference-image matching is not implemented.

Definition in file loomcam.c.

Macro Definition Documentation

◆ LOOM_DECIMAL_RADIX

#define LOOM_DECIMAL_RADIX   10

The CLI accepts decimal photo numbers, never signed or truncated IDs.

Definition at line 46 of file loomcam.c.

◆ LOOM_SELF_TEST_LATITUDE

#define LOOM_SELF_TEST_LATITUDE   INT32_C(1)

Nonzero latitude fixture checks that no-match clears stale evidence.

Definition at line 53 of file loomcam.c.

◆ LOOM_SELF_TEST_SEQUENCE

#define LOOM_SELF_TEST_SEQUENCE   UINT32_C(1)

Nonzero fixtures deliberately expose failure to clear previous state.

Definition at line 51 of file loomcam.c.

◆ LOOM_SELF_TEST_SEQUENCE_OVERFLOW

#define LOOM_SELF_TEST_SEQUENCE_OVERFLOW   "4294967296"

First integer outside the accepted uint32_t correlation range.

Definition at line 55 of file loomcam.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LOOM_CONFIRMATION_TIMEOUT_MS 

Definition at line 49 of file loomcam.c.

◆ loom_cli_layout

argv[0] is the program name; a sole flag gives two total arguments.

Enumerator
LOOM_FIRST_OPTION_INDEX 
LOOM_SINGLE_OPTION_ARGC 

Definition at line 48 of file loomcam.c.

Function Documentation

◆ description_field()

bool description_field ( const struct exif_value * description,
const char * key,
char value[64] )
static

Require a uniquely identified flight-description value.

Parameters
descriptionEXIF description to scan.
keyExact field prefix including the equals sign.
[out]valueBuffer for up to 63 characters and the terminator.
Returns
True only if a well-formed matching field was found.

Use the duplicate-aware lookup even when absence is an error.

Definition at line 110 of file loomcam.c.

◆ description_lookup()

bool description_lookup ( const struct exif_value * description,
const char * key,
char value[64],
bool * found )
static

Read one bounded observation field from an already-fetched EXIF description.

Definition at line 75 of file loomcam.c.

◆ description_number()

bool description_number ( const struct exif_value * description,
const char * key,
double * number )
static

Read a required finite numeric metadata field.

Parameters
descriptionEXIF description to scan.
keyExact field prefix including the equals sign.
[out]numberParsed value, written on success.
Returns
True for a present, fully parsed number.

Reject missing and malformed fields alike when no default is allowed.

Definition at line 122 of file loomcam.c.

◆ description_optional_number()

bool description_optional_number ( const struct exif_value * description,
const char * key,
double default_value,
double * number )
static

Read numeric metadata with a default for absence only.

Parameters
descriptionEXIF description to scan.
keyExact field prefix including the equals sign.
default_valueResult if the key is absent.
[out]numberParsed or default value on success.
Returns
False for malformed or duplicate evidence, even if a default exists.

Keep corrupt evidence distinct from older records missing an optional field.

Definition at line 135 of file loomcam.c.

◆ feature_u64()

uint64_t feature_u64 ( const unsigned char * bytes)
static

Decode an unsigned field from LOOM's little-endian record.

Parameters
bytesAt least eight readable bytes.
Returns
Decoded unsigned value.

Assemble bytes rather than reading a native word at a potentially unaligned record offset.

Definition at line 180 of file loomcam.c.

◆ main()

int main ( int argc,
char ** argv )

Parse one saved-photo request and emit exactly one correlated result line.

Parameters
argcNumber of program-name and option/value arguments.
argvBorrowed command-line tokens; paths are passed without a shell.
Returns
EXIT_SUCCESS for a processed photo, including no-match; EXIT_FAILURE for invalid input or output failure. Diagnostics use stderr, results stdout.

The embedded entry point shares the C++ capture executable but does not acquire the sensor. A syntactically successful reply is not a valid match.

Definition at line 592 of file loomcam.c.

◆ match_previous_photos()

bool match_previous_photos ( const struct loom_frame * frame,
struct camera_point_result * point )
static

Interpret retained same-photo neural vectors under the declared return contract.

Parameters
frameCurrent saved AIcam photo and reference/model configuration.
pointRequired destination in camera-point wire units.
Returns
False when model/pose/identity/direction validation rejects the photo.
Warning
Never replace no-match with the current pose, home position or guessed direction: those would look like valid navigation evidence on the FC.

Generic embeddings are never guessed to be return directions. Only the PC simulation harness may turn them into an explicitly marked mock vector. The persistent owner subsequently limits movement and suppresses stale phases.

Definition at line 240 of file loomcam.c.

◆ parse_sequence()

bool parse_sequence ( const char * text,
uint32_t * sequence )
static

Parse a nonzero correlation sequence without truncation or signed input.

Parameters
textEntire decimal token; no whitespace, sign or suffix is accepted.
[out]sequenceDestination, written only on successful validation.
Returns
True for a positive uint32_t photo number; false otherwise.

Definition at line 384 of file loomcam.c.

◆ read_onnx_descriptor_identity()

bool read_onnx_descriptor_identity ( const struct inference_settings * settings,
char graph[65],
char descriptor[65] )
static

Read the graph and descriptor identities declared by the model metadata.

Parameters
settingsSelected model and descriptor paths.
[out]graphBuffer for the declared graph digest.
[out]descriptorBuffer for the descriptor digest.
Returns
True after parsing the bounded descriptor and checking model readability.

Read descriptor identity without creating a runtime session. This helper does not hash the graph file itself.

Definition at line 155 of file loomcam.c.

◆ return_line()

int return_line ( char * line,
size_t capacity,
unsigned timeout_ms )
static

Split one bounded ASCII command, rejecting binary/trailing/oversized input.

Definition at line 452 of file loomcam.c.

◆ return_server()

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

Keep bounded T1 state separate from the waypoint transport transaction.

Definition at line 478 of file loomcam.c.

◆ return_settings()

bool return_settings ( const char * path,
struct inference_settings * settings,
struct loom_return_options * options )
static

Reuse common path/INI policy without opening a model or camera.

Definition at line 396 of file loomcam.c.

◆ run_onnx_in_memory()

bool run_onnx_in_memory ( const struct inference_settings * settings,
const struct loom_return_options * options,
const char * image,
uint64_t sequence,
uint64_t timestamp_ns,
unsigned char * record,
size_t capacity,
size_t * record_size )
static

Generate bounded LOOM feature evidence for an existing JPEG.

Parameters
settingsONNX model assignment and runtime configuration.
optionsContract that governs acceptable output shape.
imageInput JPEG path.
sequenceFrame identity to embed.
timestamp_nsSensor timestamp in nanoseconds to embed.
[out]recordDestination for packed feature evidence.
capacityAvailable bytes in record.
[out]record_sizePacked length; use only on success.
Returns
True after successful inference and packing.

Validate tensor shape before inference, enforce the stricter direction-vector shape when required, and serialize before closing the session. Calls must not overlap because the context is shared.

Definition at line 200 of file loomcam.c.

◆ self_test()

int self_test ( void )
static

Hardware-free check that the empty matcher cannot manufacture a waypoint.

Returns
EXIT_SUCCESS when clearing, correlation and invalid-ID rejection hold.
Note
The image is not opened here; this tests the stub contract, not capture.

Definition at line 567 of file loomcam.c.

◆ simulation_mode()

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

Describe whether PC imagery can run a selected ONNX graph.

Definition at line 417 of file loomcam.c.