Skip to main content

preprocess_image

Function preprocess_image 

Source
pub fn preprocess_image(
    image: &DynamicImage,
    target_size: (usize, usize),
    stride: u32,
) -> PreprocessResult
Expand description

Preprocess an image for YOLO inference.

Performs letterbox resizing, BGR to RGB conversion (if needed), normalization to [0, 1], and conversion to NCHW tensor format.

§Arguments

  • image - Input image.
  • target_size - Target size as (height, width).
  • stride - Model stride for padding alignment (typically 32).

§Returns

Preprocessed tensor and transform information for post-processing.