Loading...
Searching...
No Matches
lwir_spotter.c
Go to the documentation of this file.
112 return S_ISREG(after->st_mode) && before->st_dev == after->st_dev && before->st_ino == after->st_ino
122 if (!filename || !shot || !timing || shot->data.nr <= 0 || !capture_timing_valid(timing)) return -1;
147 const bool aligned = profile_loaded && capture_observation_exposure(observation) && observation->pose_valid
149 && observation->pose_uncertainty_m >= 0 && observation->pose_uncertainty_m <= maximum_uncertainty_m
164 int count = snprintf(output_path, sizeof(output_path), "%.*s.lwir-objects.ini", (int)length - 4, filename);
174 "pose_valid=%u\npose_uncertainty_m=%.9g\nmaximum_interval_us=%llu\nmaximum_uncertainty_m=%.9g\n"
175 "latitude_deg=%.9f\nlongitude_deg=%.9f\nagl_m=%.9g\nroll_deg=%.9g\npitch_deg=%.9g\nyaw_deg=%.9g\n"
177 shot->data.nr, request, (unsigned long long)geometry.sequence, (unsigned long long)geometry.arrival_us,
178 geometry.boot_id, geometry.frame_sha256, detections.image_sha256, detections.count, aligned ? 1U : 0U,
180 (unsigned long long)observation->latest_us, observation->pose_valid ? 1U : 0U, observation->pose_uncertainty_m,
182 pose.latitude_deg, pose.longitude_deg, pose.agl_m, pose.roll_deg, pose.pitch_deg, pose.yaw_deg);
183 fprintf(output, "model_sha256=%s\nmodel_descriptor_sha256=%s\n", detections.model_sha256, detections.descriptor_sha256);
184 struct lwir_render_options orientation = {.rotation = geometry.rotation, .mirror = geometry.mirror, .flip = geometry.flip};
199 || !lwir_render_native_coordinate(256, 192, &orientation, 0, 1, &down_x, &down_y)) { valid = false; break; }
200 center_x = origin_x + box->center_x * ((double)right_x - origin_x) + box->center_y * ((double)down_x - origin_x);
201 center_y = origin_y + box->center_x * ((double)right_y - origin_y) + box->center_y * ((double)down_y - origin_y);
204 struct lwir_measurement measurement = {.kind = LWIR_POINT, .roi = {.x = native_x, .y = native_y}};
206 if (!lwir_measure_temperature(combined, sizeof(combined), 256, 192, &measurement, NULL, &temperature)) { valid = false; break; }
207 fprintf(output, "detection.%u.label=%s\ndetection.%u.confidence=%.9g\ndetection.%u.native_x=%u\n"
212 "detection.%u.box_display=%u,%u,%u,%u\ndetection.%u.temperature_sample_method=nearest_native_pixel\n",
214 if (!temperature.endpoint_codes) fprintf(output, "detection.%u.reported_celsius=%.9g\n", index, temperature.min_raw / 64.0 - 273.15);
216 const bool projected = aligned && coverage_project_pixel(&profile.calibration, &pose, center_x, center_y, &offset);
222 index, pose.longitude_deg + offset.east * degrees_per_metre / cos(pose.latitude_deg / radians_to_degrees));
Allocation-free flat key=value mechanics; callers own schemas and storage.
static bool ini_uint(const char *text, uint64_t *number)
Parse digits-only uint64; overflow and signs are rejected.
Definition bounded_ini.h:52
static bool ini_real(const char *text, double *number)
Parse finite decimal/exponent notation, rejecting range errors and suffixes.
Definition bounded_ini.h:67
bool usher_camera_profile_read(const char *filename, struct usher_camera_profile *profile)
Read a bounded PANGEA_CAMERA_V1 key=value calibration file.
Definition camera_profile.c:132
Public C API for reading PANGEA camera calibration profiles.
static bool capture_timing_valid(const struct capture_timing *timing)
Check whether timing evidence is internally consistent and recent.
Definition capture_timing.h:155
static const char * capture_time_name(enum capture_time_kind kind)
Get the text label used when recording observation timing.
Definition capture_timing.h:115
static bool capture_observation_exposure(const struct capture_observation *observation)
Distinguish exposure evidence from other valid observation times.
Definition capture_timing.h:78
bool coverage_project_pixel(const struct coverage_camera *camera, const struct coverage_pose *pose, double column, double row, struct coverage_point *offset)
Project an image pixel onto the same ground plane as the coverage footprint.
Definition coverage_scheduler.c:88
void imx500_pipe_stop(struct imx500_pipe *pipe)
Close the channel, allow an exit grace period, then kill/reap if needed.
Definition imx500_pipe.c:132
int imx500_pipe_start(struct imx500_pipe *pipe)
Replace any owned worker and require its exact READY response.
Definition imx500_pipe.c:149
int imx500_pipe_analyze(struct imx500_pipe *pipe, const char *filename, unsigned number)
Submit one saved-picture request to a warm analysis worker without recapturing pixels.
Definition imx500_pipe.c:239
READY/SHOT/OK process ownership without model-analysis semantics.
#define IMX500_PIPE_INITIALIZER
Safe empty lifecycle state: descriptor zero must never mean uninitialized.
Definition imx500_pipe.h:49
int lwir_read_temperature_evidence(const char *filename, uint8_t *destination, size_t capacity, struct lwir_saved_geometry *geometry)
Open filename safely and read layer plus geometry; see lwir_container.h.
Definition lwir_container.c:250
Exact thermal evidence in JPEG containers, independent of analysis.
bool lwir_measure_temperature(const uint8_t *frame, size_t bytes, unsigned width, unsigned height, const struct lwir_measurement *measurement, const struct lwir_thresholds *thresholds, struct lwir_temperature_stats *statistics)
Measure a point, line or rectangle in native coordinates.
Definition lwir_frame.c:326
static uint16_t temperature(const uint8_t *frame, size_t pixels, size_t pixel)
Read one little-endian thermal code.
Definition lwir_render.c:63
bool lwir_render_native_coordinate(unsigned width, unsigned height, const struct lwir_render_options *options, unsigned display_x, unsigned display_y, unsigned *native_x, unsigned *native_y)
Convert a display coordinate into native sensor coordinates.
Definition lwir_render.c:191
Display rendering of Tiny1-C frames into JPEG-ready Y/Cb/Cr scanlines.
bool lwir_spotter_profile(const char *filename)
Load a native LWIR intrinsics and mount profile.
Definition lwir_spotter.c:63
int lwir_spotter_analyze(const char *filename, const union dc_shot_union *shot, const struct capture_timing *timing, const volatile sig_atomic_t *running)
Analyse one immutable image with copied capture evidence; no camera is acquired.
Definition lwir_spotter.c:118
static bool same_file(const struct stat *before, const struct stat *after)
Check whether an image still matches its pre-analysis metadata.
Definition lwir_spotter.c:110
bool lwir_spotter_enabled(void)
Test whether saved-LWIR analysis was explicitly selected.
Definition lwir_spotter.c:91
bool lwir_spotter_settings(const char *settings)
Select a separate ONNX detector assignment.
Definition lwir_spotter.c:56
bool lwir_spotter_limits(const char *limits)
Set the timing and pose uncertainty limits for projection.
Definition lwir_spotter.c:74
Serialized saved-LWIR object analysis with immutable frame and exposure evidence.
bool spotter_cam_pipe_read_detections(const char *filename, struct spotter_detections *detections)
Read the full detector result associated with a JPEG.
Definition spotter_cam_pipe.c:345
Native USHER adapter for on-sensor detection or photo-only capture.
Definition capture_timing.h:41
Shared observation evidence with optional LWIR request/frame-delivery timing.
Definition capture_timing.h:133
unsigned width
Delivered width in pixels; must agree with the saved image, not the sensor mode alone.
Definition coverage_scheduler.h:42
Local ground coordinates in metres, east and north of the projection origin.
Definition coverage_scheduler.h:73
double north
Metres north of the shared local geographic reference.
Definition coverage_scheduler.h:73
Pose estimate and its positional margin for a single observation.
Definition coverage_scheduler.h:59
double latitude_deg
Observation latitude in geographic degrees, not FC fixed-point units.
Definition coverage_scheduler.h:60
One caller-serialized native worker and its borrowed configuration.
Definition imx500_pipe.h:35
Display policy for one rendering request; never affects stored samples.
Definition lwir_render.h:103
Native geometry and identity recovered from the APP14 "LWIREV02" text.
Definition lwir_container.h:80
Raw-unit measurement results; derive mean/variance from the sums and pixels.
Definition lwir_frame.h:98
Definition spotter_cam_pipe.h:40
Definition spotter_cam_pipe.h:48
One measured camera calibration loaded from the flat PANGEA profile format.
Definition camera_profile.h:41
Definition usher_protocol.h:51
struct dc_shot_union::@351207206061007345226276304225222200157171312155 data