/** * Image Preprocessor for TFLite Models * * Converts images to the format expected by TFLite models: * - Resized to model input size (e.g., 640x640) * - Normalized to [0, 1] range * - As Float32Array in NHWC format (batch, height, width, channels) * * This implementation uses react-native-skia for image manipulation. * Install with: npm install @shopify/react-native-skia */ export interface PreprocessOptions { /** Target width (default: 640) */ width?: number; /** Target height (default: 640) */ height?: number; /** Normalize to [0, 1] range (default: true) */ normalize?: boolean; /** Whether to apply letterboxing to maintain aspect ratio (default: true) */ letterbox?: boolean; } export interface PreprocessResult { /** Preprocessed pixel data as Float32Array */ data: Float32Array; /** Original image width */ originalWidth: number; /** Original image height */ originalHeight: number; /** Scale factors for mapping back to original */ scale: { x: number; y: number; }; /** Padding applied (if letterboxing) */ padding: { x: number; y: number; }; } /** * Preprocess an image for TFLite model inference * * @param uri Image URI (file:// or http://) * @param options Preprocessing options * @returns Preprocessed image data */ export declare function preprocessImage(uri: string, options?: PreprocessOptions): Promise; /** * Preprocess a VisionCamera frame for TFLite inference * * This requires vision-camera-resize-plugin to be installed: * npm install vision-camera-resize-plugin * * Usage in a frame processor: * ``` * const frameProcessor = useFrameProcessor((frame) => { * 'worklet'; * const resized = resize(frame, { * size: { width: 640, height: 640 }, * pixelFormat: 'rgb', * dataType: 'float32', * }); * const result = model.runSync([resized]); * // Process result... * }, [model]); * ``` */ export declare function getFrameProcessorInstructions(): string; /** * Convert Float32Array from HWC to NHWC format (add batch dimension) */ export declare function addBatchDimension(data: Float32Array): Float32Array; /** * Check if Skia is available for image preprocessing */ export declare function isSkiaAvailable(): boolean; /** * Initialize Skia module (call before using Skia-dependent functions) * @returns true if Skia was loaded successfully */ export declare function initSkia(): Promise; /** * Check if resize plugin is available for frame processing */ export declare function isResizePluginAvailable(): Promise; //# sourceMappingURL=imagePreprocessor.d.ts.map