-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (27 loc) · 1.08 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
window.onload=function(){
const player = document.getElementById('player')
const snapshotZone = document.getElementById('snapshot')
const captureButton = document.getElementById('capture')
const result = document.getElementById('result')
navigator.mediaDevices.getUserMedia({ video: true }).then(stream => {
player.srcObject = stream
})
captureButton.addEventListener('click', function() {
result.value = "loading...";
const context = snapshot.getContext('2d')
context.drawImage(player, 0, 0, snapshotZone.width, snapshotZone.height)
// Tesseract.recognize(snapshotZone, 'jpn', { logger: m => console.log(m) }) // 日本語
Tesseract.recognize(snapshotZone, 'eng', { logger: m => console.log(m) })
.then(({ data: { words } }) => {
var arrayLength = words.length;
for (var i = 0; i < arrayLength; i++) {
console.log(words[i].text)
if (words[i].text.includes('-') && words[i].text.length >2 )
result.value = words[i].text
//Do something
if (i == arrayLength-1 && result.value =="loading...")
result.value = "No Cardnumber found!"
}
})
})
}