javascript - tesseract.js sample code not working -
i'm trying make tesseract.js working.
i have taken simple code web, apprarently declared working, doesn't.
<html> <head> <script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script> <title>tesseract test</title> </head> <body> <label for="fileinput">choose file ocr:</label> <input type="file" id="fileinput" name="fileinput"/> <br /> <br /> <div id="document-content"> </div> </body> <script> document.addeventlistener('domcontentloaded', function(){ var fileinput = document.getelementbyid('fileinput'); fileinput.addeventlistener('change', handleinputchange); }); function handleinputchange(event){ var input = event.target; var file = input.files[0]; console.log(file); tesseract.recognize(file) .progress(function(message){ console.log(message); }) .then(function(result){ var contentarea = document.getelementbyid('document-content'); console.log(result); }) .catch(function(err){ console.error(err); }); } </script> </html>
this main website: http://tesseract.projectnaptha.com/
works me, had make change:
.then(function(result) { var contentarea = document.getelementbyid('document-content'); contentarea.innerhtml = result.text; })
(the example posted logs console.)
Comments
Post a Comment