Loading...
Searching...
No Matches
lwir_frame.c
Go to the documentation of this file.
84bool lwir_measurement_valid(unsigned width, unsigned height, const struct lwir_measurement *measurement)
88 if (!measurement->roi.width) return !measurement->roi.x && !measurement->roi.y && !measurement->roi.height;
93 (measurement->kind == LWIR_POINT || (measurement->end_x < width && measurement->end_y < height));
104static uint16_t thermal_sample(const uint8_t *plane, unsigned width, unsigned column, unsigned row)
156static void accumulate_temperature(struct lwir_temperature_stats *result, uint16_t raw, unsigned column,
189static uint16x8_t thermal_block(const uint8_t *plane, unsigned width, unsigned column, unsigned row)
235static void accumulate_block(struct lwir_temperature_stats *result, uint16x8_t samples, uint16x8_t centers,
240 result->min_raw = minimum; result->min_x = column + first_equal(samples, minimum); result->min_y = row;
243 result->max_raw = maximum; result->max_x = column + first_equal(samples, maximum); result->max_y = row;
246 result->sum_squared_raw += vaddlvq_u32(vmull_u16(vget_low_u16(samples), vget_low_u16(samples)));
247 result->sum_squared_raw += vaddlvq_u32(vmull_u16(vget_high_u16(samples), vget_high_u16(samples)));
253 const unsigned below = vaddlvq_u16(vshrq_n_u16(vandq_u16(valid, vcltq_u16(centers, vdupq_n_u16(thresholds->low))), 15));
254 const unsigned above = vaddlvq_u16(vshrq_n_u16(vandq_u16(valid, vcgtq_u16(centers, vdupq_n_u16(thresholds->high))), 15));
273 uint32x4_t quotient = vcvtq_u32_f32(vdivq_f32(vcvtq_f32_u32(numerator), vcvtq_f32_u32(denominator)));
274 quotient = vsubq_u32(quotient, vshrq_n_u32(vcgtq_u32(vmulq_u32(quotient, denominator), numerator), 31));
276 return vaddq_u32(quotient, vshrq_n_u32(vcleq_u32(vmulq_u32(next, denominator), numerator), 31));
294static uint16x8_t average_block(const uint8_t *plane, unsigned width, unsigned height, unsigned column, unsigned row, uint16x8_t centers)
302 const uint16x8_t samples = thermal_block(plane, width, horizontal, vertical), valid = valid_block(samples);
304 low_sum = vaddw_u16(low_sum, vget_low_u16(accepted)); high_sum = vaddw_u16(high_sum, vget_high_u16(accepted));
311 const uint16x8_t averaged = vcombine_u16(vmovn_u32(exact_block_divide(low_sum, vmovl_u16(vget_low_u16(safe_count)))),
326bool lwir_measure_temperature(const uint8_t *frame, size_t bytes, unsigned width, unsigned height,
348 const uint16_t raw = measurement_sample(plane, width, height, (unsigned)column, (unsigned)row, measurement->average_3x3, center);
369 accumulate_temperature(&result, measurement_sample(plane, width, height, column, row, true, center), column, row, thresholds, center);
373 for (; region.x + region.width - column >= 8 && (!measurement->average_3x3 || column + 8 < width); column += 8) {
375 const uint16x8_t samples = measurement->average_3x3 ? average_block(plane, width, height, column, row, centers) : centers;
381 const uint16_t raw = measurement_sample(plane, width, height, column, row, measurement->average_3x3, center);
432bool lwir_frame_is_neutral_fill(const uint8_t *frame, size_t bytes, unsigned width, unsigned height)
446bool lwir_frame_capture_valid(const uint8_t *frame, size_t bytes, unsigned width, unsigned height)
448 if (!lwir_frame_valid(frame, bytes, width, height) || lwir_frame_is_neutral_fill(frame, bytes, width, height)) return false;
501 if (frame == NULL || previous_image == NULL || lwir_frame_bytes(width, height) == 0) return false;
Bounded C11 EXIF metadata and JPEG streaming interfaces.
bool lwir_frame_is_neutral_fill(const uint8_t *frame, size_t bytes, unsigned width, unsigned height)
Detect the camera's whole-frame neutral fill.
Definition lwir_frame.c:432
static uint16_t measurement_sample(const uint8_t *plane, unsigned width, unsigned height, unsigned column, unsigned row, bool average, uint16_t center)
Measured value of one center, optionally 3x3-averaged.
Definition lwir_frame.c:124
bool lwir_measurement_valid(unsigned width, unsigned height, const struct lwir_measurement *measurement)
Validate a measurement request against native geometry.
Definition lwir_frame.c:84
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
bool lwir_frame_valid(const uint8_t *frame, size_t bytes, unsigned width, unsigned height)
Structural check: non-NULL, supported geometry, exact combined size.
Definition lwir_frame.c:420
static uint16_t thermal_sample(const uint8_t *plane, unsigned width, unsigned column, unsigned row)
Read one little-endian thermal code.
Definition lwir_frame.c:104
static void accumulate_temperature(struct lwir_temperature_stats *result, uint16_t raw, unsigned column, unsigned row, const struct lwir_thresholds *thresholds, uint16_t center)
Add one measured sample to running statistics.
Definition lwir_frame.c:156
bool lwir_frame_capture_valid(const uint8_t *frame, size_t bytes, unsigned width, unsigned height)
Live-capture qualification.
Definition lwir_frame.c:446
bool lwir_frame_plausible(const uint8_t *frame, size_t bytes, unsigned width, unsigned height)
Conservative scene-plausibility heuristic.
Definition lwir_frame.c:465
bool lwir_roi_valid(unsigned width, unsigned height, const struct lwir_roi *roi)
Check that a non-empty rectangle lies entirely inside the image.
Definition lwir_frame.c:70
bool lwir_temperature_statistics(const uint8_t *frame, size_t bytes, unsigned width, unsigned height, const struct lwir_roi *roi, struct lwir_temperature_stats *statistics)
Rectangle statistics without averaging or thresholds.
Definition lwir_frame.c:394
size_t lwir_frame_bytes(unsigned width, unsigned height)
Combined frame size for supported geometry.
Definition lwir_frame.c:56
static unsigned byte_difference(uint8_t first, uint8_t second)
Absolute difference of two bytes without signed overflow concerns.
Definition lwir_frame.c:411
bool lwir_frame_settled(const uint8_t *frame, const uint8_t *previous_image, unsigned width, unsigned height)
Image-stability heuristic between consecutive frames.
Definition lwir_frame.c:498
Native frame arithmetic and camera measurements; no codec or flight dependencies.
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
Display rendering of Tiny1-C frames into JPEG-ready Y/Cb/Cr scanlines.
Native rectangle; a zero width/height pair selects the full image.
Definition lwir_frame.h:61
Raw-unit measurement results; derive mean/variance from the sums and pixels.
Definition lwir_frame.h:98
Optional coverage band counted alongside measurement statistics.
Definition lwir_frame.h:89