You can find the Tesseract JS Wrapper that I am referring to here.
What we want to acplish:
- 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=".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!
You can find the Tesseract JS Wrapper that I am referring to here.
What we want to acplish:
- 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!
Share Improve this question edited Nov 14, 2016 at 16:08 BanksySan 28.6k36 gold badges125 silver badges230 bronze badges asked Apr 26, 2016 at 16:30 TrevorTrevor 1,4543 gold badges16 silver badges33 bronze badges 2- You may want to pare the results vs. the Google Cloud Vision API. – Dan Dascalescu 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. – Rivalus Commented Nov 29, 2018 at 10:45
2 Answers
Reset to default 1From https://github./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)
}
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.