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

Parse the bounded, flat PANGEA camera calibration format. More...

#include "camera_profile.h"
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
Include dependency graph for camera_profile.c:

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   200809L
#define CAMERA_PROFILE_FIELD_COUNT   11

Functions

static char * trim (char *text)
 Trim surrounding whitespace in a mutable field.
static bool parse_uint (const char *text, uint64_t *number)
 Parse an exact unsigned decimal field.
static bool parse_real (const char *text, double *number)
 Parse a finite camera geometry value.
static bool read_file (const char *filename, char *buffer, size_t capacity, size_t *length)
 Read one bounded, text-only snapshot of a profile.
bool usher_camera_profile_read (const char *filename, struct usher_camera_profile *profile)
 Read a bounded PANGEA_CAMERA_V1 key=value calibration file.

Detailed Description

Parse the bounded, flat PANGEA camera calibration format.

Require all fields, finite geometry values, and a stable regular-file read before publishing the parsed record. A valid profile can still have an unknown USHER camera ID; the consumer checks identity and geometry for its use.

Definition in file camera_profile.c.

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Definition at line 25 of file camera_profile.c.

◆ CAMERA_PROFILE_FIELD_COUNT

#define CAMERA_PROFILE_FIELD_COUNT   11

Definition at line 38 of file camera_profile.c.

Function Documentation

◆ parse_real()

bool parse_real ( const char * text,
double * number )
static

Parse a finite camera geometry value.

Parameters
textNull-terminated numeric field.
[out]numberResult written only on success.
Returns
True if the full field converted without a range error.

Reject non-finite values before they can propagate into projection.

Definition at line 79 of file camera_profile.c.

◆ parse_uint()

bool parse_uint ( const char * text,
uint64_t * number )
static

Parse an exact unsigned decimal field.

Parameters
textNull-terminated decimal digits without sign or suffix.
[out]numberResult written only on success.
Returns
True for a nonempty value representable as uint64_t.

Check headroom before multiplying so an overflowing value cannot wrap into a plausible raster dimension.

Definition at line 60 of file camera_profile.c.

◆ read_file()

bool read_file ( const char * filename,
char * buffer,
size_t capacity,
size_t * length )
static

Read one bounded, text-only snapshot of a profile.

Parameters
filenamePath to the profile.
[out]bufferWritable storage for the text and terminator.
capacityBuffer size, greater than the profile size limit.
[out]lengthBytes of text before the terminator; use only on success.
Returns
True for a stable, nonempty regular-file read and successful close.

Open nonblocking so a non-regular input does not stall the owner. Compare size and modification time after reading to detect ordinary concurrent changes; this is not a content integrity check.

Definition at line 99 of file camera_profile.c.

◆ trim()

char * trim ( char * text)
static

Trim surrounding whitespace in a mutable field.

Parameters
[in,out]textNull-terminated input.
Returns
Borrowed pointer to the start of the trimmed field.

Advance past leading whitespace and terminate in place to keep parsing within the original file buffer.

Definition at line 45 of file camera_profile.c.

◆ usher_camera_profile_read()

bool usher_camera_profile_read ( const char * filename,
struct usher_camera_profile * profile )

Read a bounded PANGEA_CAMERA_V1 key=value calibration file.

Parameters
[in]filenameProfile path; comments and blank lines are allowed.
[out]profileReceives parsed geometry and filename prefix; unchanged on failure.
Returns
True only when all required fields are present and valid.

No heap allocation is performed. Duplicate and unknown keys are rejected so a typo cannot silently select a different camera calibration. A valid mapping prefix may have no USHER camera ID (reported as zero); consumers also check that the calibration satisfies their geometry constraints.

Definition at line 132 of file camera_profile.c.