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

Native calibration and projection; no detector, JPEG codec or flight parser. More...

#include "lwir_geolocation.h"
#include "lwir_frame.h"
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Include dependency graph for lwir_geolocation.c:

Go to the source code of this file.

Enumerations

enum  { lwir_calibration_max = 8192 }
enum  ned_axis { NED_NORTH , NED_EAST , NED_DOWN }
 Axis identities for rays and lever arms after rotation into NED. More...

Functions

static bool parse_number (const char **cursor, double *value)
 Parse one finite number at a cursor, skipping surrounding blanks.
static bool parse_scalar (const char *text, double *value)
 Parse a value that must be exactly one number, optionally followed by a comment.
static bool parse_unsigned_scalar (const char *text, unsigned *value)
 Parse a nonnegative decimal integer that fits in unsigned int.
static bool parse_array (const char *text, double *values, size_t count)
 Parse a single-line flow array [a, b, ...] with exactly count numbers.
bool lwir_geolocation_load_calibration (const char *path, unsigned width, unsigned height, struct lwir_camera_geometry *geometry)
 Load a calibration profile for one native image size.
static void rotate_vector (const double matrix[9], const double vector[3], double result[3])
 Multiply a row-major 3x3 matrix by a 3-vector.
bool lwir_geolocation_project (double pixel_x, double pixel_y, const struct lwir_camera_geometry *camera, const struct lwir_camera_pose *pose, struct lwir_ground_point *point)
 Project a native subpixel location onto the local ground plane.

Detailed Description

Native calibration and projection; no detector, JPEG codec or flight parser.

Analysis builds only (LWIR_ENABLE_ANALYSIS=1). Provides a bounded, line-oriented calibration reader and a pixel-to-ground projection used on hotspots found in saved LWIR JPEG temperature planes. Fixed-size buffers only; no heap allocation. See lwir_geolocation.h for frame conventions and model limits.

Definition in file lwir_geolocation.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
lwir_calibration_max 

Definition at line 40 of file lwir_geolocation.c.

◆ ned_axis

enum ned_axis

Axis identities for rays and lever arms after rotation into NED.

Enumerator
NED_NORTH 
NED_EAST 
NED_DOWN 

Definition at line 43 of file lwir_geolocation.c.

Function Documentation

◆ lwir_geolocation_load_calibration()

bool lwir_geolocation_load_calibration ( const char * path,
unsigned width,
unsigned height,
struct lwir_camera_geometry * geometry )

Load a calibration profile for one native image size.

Load bounded projection calibration, requiring exact native dimensions.

Reads key: value lines (a YAML-like subset) into a local copy and publishes it only after all checks pass, so geometry is never half-written. A bitmask of seen keys detects duplicates and missing required keys.

Returns
True for a structurally valid profile; false for I/O errors, a non-regular/empty/oversized file, syntax errors, duplicates, missing keys or out-of-range values.

Definition at line 137 of file lwir_geolocation.c.

◆ lwir_geolocation_project()

bool lwir_geolocation_project ( double pixel_x,
double pixel_y,
const struct lwir_camera_geometry * camera,
const struct lwir_camera_pose * pose,
struct lwir_ground_point * point )

Project a native subpixel location onto the local ground plane.

Project a native subpixel location using distortion, mount and observation pose.

Steps:

  1. Validate every input (finite, in range, proper rotation).
  2. Pixel -> distorted normalized coordinates via intrinsics.
  3. Invert Brown-Conrady distortion by fixed-point iteration.
  4. Build the camera ray (x, y, 1), rotate camera -> body -> NED.
  5. Intersect with the plane agl_m below the navigation reference, starting from the lever-arm-offset camera origin.
  6. Convert the NED offset to WGS84 latitude/longitude via ECEF.
    Returns
    False for invalid inputs, an improper mount rotation, nonconvergent undistortion, a ray too close to the horizon, or a camera origin at/below the ground plane.
    Note
    Pixel coordinates are combined with cx/cy as-is, so they must follow the calibration's convention (OpenCV: integer coordinates at pixel centres).

Definition at line 275 of file lwir_geolocation.c.

◆ parse_array()

bool parse_array ( const char * text,
double * values,
size_t count )
static

Parse a single-line flow array [a, b, ...] with exactly count numbers.

Parameters
textNUL-terminated value text.
[out]valuesReceives count numbers; may be partially written on failure.
countRequired element count; more or fewer elements fail.
Returns
True for a well-formed array optionally followed by a comment.

Definition at line 111 of file lwir_geolocation.c.

◆ parse_number()

bool parse_number ( const char ** cursor,
double * value )
static

Parse one finite number at a cursor, skipping surrounding blanks.

Rejects an empty field or a leading list/comment delimiter before calling strtod(), and requires the whole parsed value to be finite.

Parameters
[in,out]cursorAdvanced past the number and trailing blanks on success.
[out]valueWritten only on success.
Returns
False for empty, unparsable, ERANGE, NaN or infinite input.

Definition at line 53 of file lwir_geolocation.c.

◆ parse_scalar()

bool parse_scalar ( const char * text,
double * value )
static

Parse a value that must be exactly one number, optionally followed by a comment.

Parameters
textNUL-terminated value text after the key's colon.
[out]valueParsed number; may be written even when trailing text fails.
Returns
True when only blanks or a '#' comment follow the number.

Definition at line 73 of file lwir_geolocation.c.

◆ parse_unsigned_scalar()

bool parse_unsigned_scalar ( const char * text,
unsigned * value )
static

Parse a nonnegative decimal integer that fits in unsigned int.

Requires a leading digit so strtoul() cannot accept a sign ("-1" would otherwise wrap to a huge value).

Parameters
textNUL-terminated value text.
[out]valueWritten only on success.
Returns
True for a complete in-range integer, optionally followed by a comment.

Definition at line 89 of file lwir_geolocation.c.

◆ rotate_vector()

void rotate_vector ( const double matrix[9],
const double vector[3],
double result[3] )
static

Multiply a row-major 3x3 matrix by a 3-vector.

Parameters
matrixRow-major matrix.
vectorInput vector; must not alias result.
[out]resultmatrix * vector.

Definition at line 250 of file lwir_geolocation.c.