1.7 KiB
1.7 KiB
TFM aInventory - Scanner Technical Specification (v1.2)
This document defines the "Frozen" parameters for the scanner component. Do NOT modify these values without explicit user approval.
1. Hardware Access
- API: Direct
MediaStreamTrackaccess for high-performance camera control. - Zoom: Dynamic detection of
capabilities.zoom.max. - Zoom Cycle: 1x -> 2x -> Max/2 -> Max.
2. Image Pre-processing (The OCR "Secret Sauce")
Before being sent to Tesseract.js, every frame undergoes these transformations:
- Rescaling: Fixed canvas width of 1200px (Optimal for Mobile RAM/Accuracy).
- Cropping: 60% Center Crop of the video stream (forces focus & removes peripheral noise).
- Filters:
grayscale(100%) contrast(180%) brightness(105%). - Format: High-quality JPEG (
0.85quality) viatoDataURL.
3. OCR Matching Engine (page.tsx)
- Sanitization: Text normalized to UPPERCASE, non-alphanumeric replaced with spaces.
- Noise Filtering:
- Tokens < 3 chars ignored.
- Decimals (e.g.,
0.11,0.18) ignored via regex:/^\d+\.\d+$/. - Dates (e.g.,
2024-07-25) ignored via regex:/^\d{2,4}-\d{2}-\d{2}$/.
- Scoring System:
- Exact Serial Number Match: +500 points (Instant Match).
- Exact Part Number Match: +200 points.
- Token match (e.g., "LC" in "LC/UPC"): +50 points.
- Category Match: +20 points.
- Threshold: Minimum 40 points required for automatic match without user intervention.
4. UI/UX Flow
- Auto-Match: Attempt to identify item immediately from raw text.
- Interactive Selection (Fallback): If match confidence is low, freeze frame and show clickable bounding boxes for manual word selection.
Created: 2026-04-10 Status: FROZEN