tesseract.js

Tesseract.js (JavaScript OCR) 识别1D条形码下面的数字

假装没事ソ 提交于 2020-02-27 01:03:38
在做条形码识别的时候,有可能碰到条形码因为被破坏,无法识别的情况。通常1D条形码的下面都印着对应的数字。这个时候还可以借助下OCR。虽然OCR的成功率可能不高,但是多一种识别方法也是好的。这里分享下如何用Tesseract.js来识别一张1D条形码。 如何使用Tesseract.js 使用npm的命令安装Tesseract.js: npm install tesseract.js 获取示例代码: https://github.com/naptha/tesseract.js/tree/master/examples 简单的运行下这些示例代码会发现第一次运行速度很慢,原因是需要下载语言包。要加快速度可以参考 https://github.com/jeromewu/tesseract.js-offline 的示例代码,指定语言包的路径。 Node const path = require('path'); const worker = createWorker({ langPath: path.join(__dirname, '..', 'lang-data'), logger: m => console.log(m), }); (async () => { await worker.load(); await worker.loadLanguage('eng'); await

Ionic 4 with Tesseract offline getting “Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope'”

给你一囗甜甜゛ 提交于 2019-12-13 04:11:50
问题 I am trying to use Tesseract in offline mode in my Ionic 4 app. In order to do it I have based my code on what is explained in this example, although it is done with Ionic 3 and what the Tesseract GitHub explains regarding offline mode. First, I have put the Tesseract files in the src\assets\lib directory as follows (the tesseract- prefix for the files has been added by me): Next I created a service that basically creates a Tesseract offline mode instance as indicated in the above mentioned

How to use Tesseract.js in a React app

风格不统一 提交于 2019-12-07 02:17:13
问题 I am working on an app using React. I want to be able to load a pic and then have Tesseract.js convert it to text. I am using react-dropzone to load the image file and I can add the image to page with an img tag. But when I try to run the ocr using Tesseract It gives me this error: Uncaught SyntaxError: Unexpected token < at blob:http://localhost:3000/ccac34f4-1f4a-4ba6-b455-a44345b71012:1 (anonymous) @ blob:http://localhost:3000/ccac34f4-1f4a-4ba6-b455-a44345b71012:1 One post I read said to

How to use Tesseract.js in a React app

允我心安 提交于 2019-12-05 07:12:00
I am working on an app using React. I want to be able to load a pic and then have Tesseract.js convert it to text. I am using react-dropzone to load the image file and I can add the image to page with an img tag. But when I try to run the ocr using Tesseract It gives me this error: Uncaught SyntaxError: Unexpected token < at blob: http://localhost:3000/ccac34f4-1f4a-4ba6-b455-a44345b71012:1 (anonymous) @ blob: http://localhost:3000/ccac34f4-1f4a-4ba6-b455-a44345b71012:1 One post I read said to use a CDN, but then Tesseract is not included in my build process, which throws an error. So I think