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>
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:
- Validate every input (finite, in range, proper rotation).
- Pixel -> distorted normalized coordinates via intrinsics.
- Invert Brown-Conrady distortion by fixed-point iteration.
- Build the camera ray (x, y, 1), rotate camera -> body -> NED.
- Intersect with the plane agl_m below the navigation reference, starting from the lever-arm-offset camera origin.
- 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()
|
static |
Parse a single-line flow array [a, b, ...] with exactly count numbers.
- Parameters
-
text NUL-terminated value text. [out] values Receives countnumbers; may be partially written on failure.count Required 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()
|
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] cursor Advanced past the number and trailing blanks on success. [out] value Written only on success.
- Returns
- False for empty, unparsable, ERANGE, NaN or infinite input.
Definition at line 53 of file lwir_geolocation.c.
◆ parse_scalar()
|
static |
Parse a value that must be exactly one number, optionally followed by a comment.
- Parameters
-
text NUL-terminated value text after the key's colon. [out] value Parsed 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()
|
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
-
text NUL-terminated value text. [out] value Written 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()
|
static |
Multiply a row-major 3x3 matrix by a 3-vector.
- Parameters
-
matrix Row-major matrix. vector Input vector; must not alias result.[out] result matrix * vector.
Definition at line 250 of file lwir_geolocation.c.