3

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!

2
  • You may want to compare the results vs. the Google Cloud Vision API. Commented Jul 27, 2016 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. Commented Nov 29, 2018 at 10:45

2 Answers 2

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)
        }
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.