Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading the text value or number from an image using node.js

Tags:

node.js

I want to read a number from an image using Node.js.

I am parsing the image using canvas and then reading the image but it gives me the binary data for image but I need the number value that image contains.

like image 710
Atul Agrawal Avatar asked Nov 12 '15 09:11

Atul Agrawal


3 Answers

Try:

npm install tesseract.js

Then include file in node.js

var Tesseract = require('tesseract.js');

Then

Tesseract.recognize(
  'https://tesseract.projectnaptha.com/img/eng_bw.png',
  'eng',
  { logger: m => console.log(m) }
).then(({ data: { text } }) => {
  console.log(text);
})
like image 70
Inderjeet Avatar answered Oct 15 '22 08:10

Inderjeet


Well, obviously you can't just read data off the image and get the text you need.

You need to interpret the image with some OCR (Optical character recognition) software.

What I could suggest if you are keen on using NodeJS is the node-tesseract module. Make sure to do as the Installation guide says because you also need to install the tesseract-ocr software as well as the module.

like image 25
Andrius Avatar answered Oct 15 '22 06:10

Andrius


First, do install tesseract in your machine by doing the given steps from this tessdocs(tesseract documentation).

Once you are done with the installation please try the steps from the above comment.

like image 31
Akash Srinivasan Avatar answered Oct 15 '22 07:10

Akash Srinivasan