Feature/issue 136 wasm ocr#261
Open
Subhra-Nandi wants to merge 5 commits into
Open
Conversation
…-tech#136) - Load tesseract.js inside Web Worker (off main thread) - Cache English language data in IndexedDB on first load - Message protocol: recognize -> result | error - Sends ready/init_error on startup - Handles ImageData input; returns text, confidence, per-word bbox
- recognize(imageData) -> Promise<OCRResult> matched by UUID - isReady() / waitUntilReady() track worker init state - terminate() cleans up worker and rejects all pending promises - UUID fallback for browsers without crypto.randomUUID()
- Connect to backend WebSocket ws://localhost:8000/ws/guidance - On disconnect: switch to local OCR polling every 2s - Overlay status: OCR Backend online / OCR Local offline - Auto-reconnect with 3s delay
- Mock Worker via FakeWorker class - Tests: isReady, waitUntilReady, recognize success/error/concurrent - Tests: terminate worker.terminate called, pending rejected - No real WASM or network calls - 12 passed, 0 failed
…hoo-tech#136) - Chrome 88+, Firefox 79+, Edge 88+, Safari 15.2+ supported - Required APIs table: Worker, WASM, IndexedDB, ImageData, crypto - Performance: warm cache target 800ms on 1920x1080 - IndexedDB cache behaviour and fallback strategy documented
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
Closes #136
📝 Summary of Changes
Implements a complete WebAssembly-based OCR pipeline that runs entirely
in the browser using
tesseract.js@5, with no backend call required.frontend/workers/ocr_worker.js— Web Worker that loads Tesseract WASM,caches English language data in IndexedDB, and processes
ImageDataframes.Message protocol:
recognize→result | error. Sendsreadyon init.frontend/utils/ocr_client.js—OCRClientclass wrapping the workerwith a Promise-based API.
recognize(imageData)returns a Promise matchedby UUID.
isReady(),waitUntilReady(), andterminate()manage lifecycle.frontend/renderer/app.js— Connects to backend WebSocket. On disconnect,falls back to local OCR every 2s. Overlay shows
"OCR: Backend (online)"or"OCR: Local (offline)".docs/browser_ocr_compatibility.md— Full compatibility matrix,performance benchmarks, IndexedDB cache behaviour, and fallback strategy.
🔍 Type of Change
🧪 How Was This Tested?
Test environment:
node --versionand fill in)📸 Screenshots / Recordings (if applicable)