Skip to content

chore: Web Worker Friendly Code#40

Open
rodrigo1991 wants to merge 3 commits intogutenye:mainfrom
rodrigo1991:main
Open

chore: Web Worker Friendly Code#40
rodrigo1991 wants to merge 3 commits intogutenye:mainfrom
rodrigo1991:main

Conversation

@rodrigo1991
Copy link
Copy Markdown
Contributor

Chore: Add Web Worker Friendly Code, Update Models, Update OpenCV-JS

Summary

This PR refactors the OCR browser codebase to run OCR in a Web Worker, ensuring that image processing does not block the main UI thread. It also updates the ONNX models and refreshes the OpenCV-JS dependency.

Changes

  • Refactored the OCR logic to create the Ocr instance once in a worker and reuse it across multiple images.
  • Replaced Image based loading with fetch + createImageBitmap for worker compatibility.
  • Updated detection and recognition models to the latest versions.
  • Updated OpenCV-JS to the latest stable release.
  • Updated the README to document the worker-friendly approach and provide usage instructions.

Benefits

  • Non-blocking UI: Image processing and OCR run off the main thread.
  • Reusable OCR instance: Models are loaded once per worker, improving performance.
  • Modern API: Compatible with React/Next.js applications using module workers.
  • Better maintainability: Clear separation between main thread and worker responsibilities.

@netlify
Copy link
Copy Markdown

netlify bot commented Oct 3, 2025

Deploy Preview for gutenye-ocr failed.

Name Link
🔨 Latest commit 990f39f
🔍 Latest deploy log https://app.netlify.com/projects/gutenye-ocr/deploys/68e655b7e21e5f0007e30f76

Copy link
Copy Markdown
Owner

@gutenye gutenye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@gutenye gutenye mentioned this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants