Infrastructure: Implement master/dev/vX branching, save git path, and fix username casing
This commit is contained in:
36
dev_docs/SCANNER_LOGIC_SPEC.md
Normal file
36
dev_docs/SCANNER_LOGIC_SPEC.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# 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 `MediaStreamTrack` access 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.85` quality) via `toDataURL`.
|
||||
|
||||
## 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
|
||||
1. **Auto-Match**: Attempt to identify item immediately from raw text.
|
||||
2. **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*
|
||||
Reference in New Issue
Block a user