-
-
Save kolarski/0bc2a3feb02adb1b63016d0d78b3653c to your computer and use it in GitHub Desktop.
Tesseract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<html> | |
<head> | |
<title>Tesseract-JS Demo</title> | |
</head> | |
<body> | |
<input type="text" id="url" placeholder="Image URL" /> | |
<!--<div id="ocr_results"> </div>--> | |
<div id="ocr_status"> </div> | |
<div> | |
<label>Filed1 | |
<label> | |
<textarea id="txt" ></textarea> | |
</div> | |
</body> | |
<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script> | |
function runOCR(url) { | |
Tesseract.recognize(url) | |
.then(function(result) { | |
document.getElementById("txt") | |
.innerHTML = result.text; | |
document.getElementById('txt').focus(); | |
}).progress(function(result) { | |
document.getElementById("ocr_status") | |
.innerText = result["status"] + " (" + | |
(result["progress"] * 100) + "%)"; | |
}); | |
} | |
document.getElementById("url") | |
.addEventListener("change", function(e) { | |
var url = document.getElementById("url").value; | |
runOCR(url); | |
}); | |
const urlParams = new URLSearchParams(window.location.search); | |
const myImage = urlParams.get('image'); | |
if (myImage) { | |
runOCR(myImage); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment