2

You can find the Tesseract JS Wrapper that I am referring to here.

What we want to accomplish:

  • Upload a photo of a printed document
  • Turn that photo into text

Things done to setup so far:

  • npm install tesseract.js

Here is our code:

HTML

<input id="myFileInput" type="file" accept="image/*;" capture="camera">

<img id="pic" src="rec.jpg">

JS

<script src="http://tenso.rs/tesseract.js"></script>

<script type="text/javascript">

var img = document.getElementById("pic");

Tesseract
  .recognize( img, {
    progress: show_progress} )
  .then( display )

</script>

What's happening in the Console:

"Uncaught ReferenceError: show_progress is not defined"

"hallo",

"pre-main prep time: 67 ms",


As you can see, we've abandoned the photo upload feature for the moment, until we can figure out how to get tesseract.js to work for a single, pre-provided jpg. Eventually, we hope to add this functionality.

Any help would be greatly appreciated, we're doing this for fun and are mainly seeking a simple (but effective) means of doing OCR with JavaScript. If you have another suggestion, please let us know!

BanksySan
  • 27,362
  • 33
  • 117
  • 216
Trevor
  • 1,284
  • 3
  • 15
  • 33
  • You may want to compare the results vs. the [Google Cloud Vision API](http://stackoverflow.com/questions/15229168/javascript-text-recognition-and-ocr-on-canvas/38615942#38615942). – Dan Dascalescu Jul 27 '16 at 14:37
  • Based on the answer given by user993553, you need to call a function for progress: . Or you need to write a function for show_progress. – Rivalus Nov 29 '18 at 10:45

2 Answers2

1

From https://github.com/naptha/tesseract.js/blob/a6195ef86d9673cab26120613f53c499b8ec0994/example.htm it seems show_progress must be a function.

Tesseract.recognize(canvas,{
        tessedit_char_blacklist:'e',
        progress: function(e){
            console.log(e)
        }
user993553
  • 1,077
  • 5
  • 12
0

this is my code :

Tesseract.recognize("https://yoursite/image.jpg", {
    lang: 'ind',
    tessedit_char_blacklist: 'e'
})
.progress(function(message){ console.log(message) })
.then(function(result) { console.log(result) });

put progress(function(message){ console.log(message) }) after the recognize function and it works perfectly for me.

alexanderarda
  • 390
  • 8
  • 13