/** * useVideoScanner Hook * * React hook for real-time video scanning combining product detection, * barcode scanning, and text recognition. * * @example * ```typescript * import { useVideoScanner } from '@souschef/ml-vision'; * * function LiveScanner() { * const { * isScanning, * products, * barcodes, * startScanning, * stopScanning, * cameraRef, * } = useVideoScanner({ * modes: ['products', 'barcodes'], * onDetected: (results) => console.log('Found:', results), * }); * * return ( * * ); * } * ``` */ import type { TensorflowModel } from 'react-native-fast-tflite'; import type { Camera, Frame } from 'react-native-vision-camera'; import type { ProductDetectionResult, BarcodeDetectionResult, ProductCategory } from '../types'; /** * Scanning mode */ export type ScanMode = 'products' | 'barcodes' | 'text'; /** * Combined detection result */ export interface VideoScanResult { products: ProductDetectionResult[]; barcodes: BarcodeDetectionResult[]; timestamp: number; frameNumber: number; } /** * Options for useVideoScanner hook */ export interface UseVideoScannerOptions { /** Scanning modes to enable (default: ['products', 'barcodes']) */ modes?: ScanMode[]; /** Frame rate for processing (default: 10 fps) */ targetFps?: number; /** Minimum confidence for product detection (default: 0.5) */ minProductConfidence?: number; /** Product categories to detect */ productCategories?: ProductCategory[]; /** Maximum products per frame (default: 10) */ maxProducts?: number; /** Maximum barcodes per frame (default: 5) */ maxBarcodes?: number; /** Enable temporal smoothing (default: true) */ temporalSmoothing?: boolean; /** Number of frames for smoothing (default: 3) */ smoothingFrames?: number; /** Callback when items are detected */ onDetected?: (results: VideoScanResult) => void; /** Callback on error */ onError?: (error: Error) => void; /** Enable haptic feedback (default: true) */ hapticFeedback?: boolean; /** Loaded TFLite model for on-device frame processing */ tfliteModel?: TensorflowModel | null; /** Use on-device TFLite frame processor instead of server (default: true if model provided) */ useOnDeviceFrameProcessor?: boolean; /** Only detect food classes when using COCO model (default: true) */ foodOnly?: boolean; } /** * Return type for useVideoScanner hook */ export interface UseVideoScannerReturn { /** Whether scanning is active */ isScanning: boolean; /** Whether all models are loaded */ isReady: boolean; /** Detected products (smoothed) */ products: ProductDetectionResult[]; /** Detected barcodes */ barcodes: BarcodeDetectionResult[]; /** Current frame number */ frameNumber: number; /** Average FPS */ fps: number; /** Current error if any */ error: Error | null; /** Last inference time in milliseconds */ inferenceTimeMs: number; /** Start video scanning */ startScanning: () => void; /** Stop video scanning */ stopScanning: () => void; /** Toggle scanning */ toggleScanning: () => void; /** Clear all detections */ clearDetections: () => void; /** Capture current frame as photo */ captureFrame: () => Promise; cameraRef: React.RefObject; frameProcessorConfig: unknown; /** Frame processor function for use with VisionCamera (if using TFLite) */ frameProcessor: ((frame: Frame) => void) | undefined; } /** * Hook for real-time video scanning */ export declare function useVideoScanner(options?: UseVideoScannerOptions): UseVideoScannerReturn; export default useVideoScanner; //# sourceMappingURL=useVideoScanner.d.ts.map