Trevor
Trevor

Reputation: 1414

Pass image to Tesseract.js OCR

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

What we want to accomplish:

Things done to setup so far:

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!

Upvotes: 3

Views: 14564

Answers (2)

alexanderarda
alexanderarda

Reputation: 400

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.

Upvotes: 0

user993553
user993553

Reputation: 1077

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

Upvotes: 1

Related Questions