我正在使用网络摄像头拍摄图像并尝试阅读其上的文字。现在它读取所有文本。我想只过滤图像中的字母和数字。并且还想获得文本的坐标。为了获得坐标,我遵循了link。但它不起作用。未找到此解决方案的其他参考。
<script src="ocrad.js"></script>
<script>
// Grab elements, create settings, etc.
var video = document.getElementById('video');
// Get access to the camera!
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
// Not adding `{ audio: true }` since we only want video now
navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
video.src = window.URL.createObjectURL(stream);
video.play();
});
}
// Elements for taking the snapshot
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var video = document.getElementById('video');
// Trigger photo take
document.getElementById("snap").addEventListener("click", function() {
document.getElementById('transcription').innerText = "(Recognizing...)";
context.drawImage(video, 0, 0, 640, 480);
OCRAD( canvas, function(text){
document.getElementById('transcription').className = "done"
document.getElementById('transcription').innerText = text;
})
});
</script>