Atul Agrawal
Atul Agrawal

Reputation: 1520

Reading the text value or number from an image using 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.

Upvotes: 10

Views: 27721

Answers (3)

Akash Srinivasan
Akash Srinivasan

Reputation: 119

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.

Upvotes: 1

Inderjeet
Inderjeet

Reputation: 1528

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);
})

Upvotes: 11

Andrius
Andrius

Reputation: 5939

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.

Upvotes: 7

Related Questions