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>
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()
|
static |
Parse a finite camera geometry value.
- Parameters
-
text Null-terminated numeric field. [out] number Result 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()
|
static |
Parse an exact unsigned decimal field.
- Parameters
-
text Null-terminated decimal digits without sign or suffix. [out] number Result 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()
|
static |
Read one bounded, text-only snapshot of a profile.
- Parameters
-
filename Path to the profile. [out] buffer Writable storage for the text and terminator. capacity Buffer size, greater than the profile size limit. [out] length Bytes 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()
|
static |
Trim surrounding whitespace in a mutable field.
- Parameters
-
[in,out] text Null-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] filename Profile path; comments and blank lines are allowed. [out] profile Receives 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.