Loading...
Searching...
No Matches
inference_image.c
Go to the documentation of this file.
20 * @details Resize, channel order and physical units are declared model policy, not camera defaults. */
37/** @brief Clamp full-range JPEG/YUV color conversion without changing the raw source evidence. */
43/** @brief Read one native pixel; missing thermal samples never become invented finite temperatures. */
44static bool source_pixel(const struct inference_image *image, const struct inference_image_spec *spec,
83 const unsigned pixel_bytes = image->format == INFERENCE_RGB8 ? 3 : image->format == INFERENCE_KELVIN64 ? 2 : 1;
91 if (count > ONNX_BUFFER_LIMIT / element_bytes || capacity != count * element_bytes || !isfinite(spec->padding)) goto invalid;
94 if (!isfinite(spec->scale[channel]) || !spec->scale[channel] || !isfinite(spec->mean[channel])) goto invalid;
101 /* Retain the rounded content rectangle so later box projection uses the actual resize, not an ideal scale. */
116 column - transform->left < transform->content_width && row - transform->top < transform->content_height) {
150 snprintf(error, error_capacity, "Invalid image layout, sample or model preprocessing contract");
157 if (!transform || !source_x || !source_y || !transform->content_width || !transform->content_height ||
158 !isfinite(input_x) || !isfinite(input_y) || input_x < transform->left || input_y < transform->top ||
159 input_x > transform->left + transform->content_width || input_y > transform->top + transform->content_height) return false;
bool inference_image_point(const struct inference_image_transform *transform, double input_x, double input_y, double *source_x, double *source_y)
Map a model-input point back to source pixels, rejecting letterbox-only coordinates.
Definition inference_image.c:154
static bool plane_valid(const struct inference_image *image, size_t plane, unsigned width, unsigned height, unsigned bytes)
Prove the last addressed row fits before any stride-based pointer arithmetic.
Definition inference_image.c:28
static bool source_pixel(const struct inference_image *image, const struct inference_image_spec *spec, unsigned column, unsigned row, double pixel[3])
Read one native pixel; missing thermal samples never become invented finite temperatures.
Definition inference_image.c:44
static double limited(double value)
Clamp full-range JPEG/YUV color conversion without changing the raw source evidence.
Definition inference_image.c:38
bool inference_image_prepare(const struct inference_image *image, const struct inference_image_spec *spec, void *tensor, size_t capacity, struct inference_image_transform *transform, char *error, size_t error_capacity)
Convert with the declared nearest-neighbor policy, not a guessed training transform.
Definition inference_image.c:69
Source-independent, bounded model preprocessing with reversible coordinate bookkeeping.
Model-owned preprocessing; normalized samples are (sample - mean) * scale.
Definition inference_image.h:45
Exact resized content rectangle, including rounded letterbox offsets.
Definition inference_image.h:55
Borrowed immutable planes; lengths/strides prove all addressed rows are available.
Definition inference_image.h:37