Skip to main content
Version: 0.10.x

Function: createImagePreprocessor()

createImagePreprocessor(options, outputShape): ImagePreprocessor

Defined in: extensions/cv/utils/imagePreprocessor.ts:77

Creates a reusable image preprocessor pipeline.

Configures a pipeline to resize, color convert, convert layout (HWC to CHW), normalize, and copy raw image buffers into target tensors matching model input shapes. All intermediate scratch tensors are pre-allocated and safely disposed of when calling dispose().

Parameters​

options​

ImagePreprocessorOptions

Normalization scaling coefficients, interpolation algorithms, and resize modes. See ImagePreprocessorOptions.

outputShape​

number[]

Expected output shape of the preprocessed model input tensor (must match rank-3 [3, H, W] or rank-4 [1, 3, H, W]).

Returns​

ImagePreprocessor

An instantiated ImagePreprocessor pipeline.

Throws​

With code SCHEMA_MISMATCH if outputShape does not match rank-3 [3, H, W] or rank-4 [1, 3, H, W].