Responsive Design OCR

This commit is contained in:
LukasNowy
2019-01-18 00:32:18 +01:00
parent 4cb86a2f2a
commit 40ddeb8b28
4 changed files with 32 additions and 17 deletions

View File

@ -31,5 +31,5 @@ function throwError(error) {
function snap() {
canvas.width = video.clientWidth;
canvas.height = video.clientHeight;
canvas.getContext("2d").drawImage(video, 0, 0);
canvas.getContext("2d").drawImage(video, 0, 0, canvas.width, canvas.height);
}

View File

@ -8,20 +8,30 @@ $(document).ready(function() {
});
});
var loading = false;
function analyze() {
var img = document.getElementById("canvas").toDataURL();
Tesseract.recognize(img).progress((progress) => {
console.log(progress, "$$$$");
if (progress.status == "recognizing text") {
$(".determinate").css("width", progress.progress * 100 + "%");
loading = true;
}
}).then((result) => {
console.log(result);
loading = false;
$(".output").text(result.text);
$('.modal').modal("open");
$(".determinate").css("width", "0%");
});
}
setInterval(updateProgress(), 500);
function updateProgress(percent) {
if(loading == true) {
$(".determinate").css("width", progress.progress * 100 + "%");
}
}

View File

@ -1,12 +1,17 @@
body {
background-color: #b3e5fc;
background-color: #fafafa;
}
.cont1 {
background-color: #424242;
margin-top: 1em;
padding-top: 10px;
}
.cont2 {
margin-top: 0px;
#video {
width: 100%;
}
#canvas {
width: 100%;
}