How to get an example of Ocrad.js to work

I am building an OCR (Optical Character Recognition) web application and I found the Ocrad.js JavaScript library , which is exactly what I was looking for, but I cannot get it to work. Can someone help me?

Here is my code:

<!doctype html>
<html>
    <head>
        <script src="ocrad.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
        <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
        <script>
            $(document).ready(function() {
                var image = document.getElementById('image');
                var string = OCRAD(image);
                alert(string);
            });
        </script>
    </head> 
    <body>
        <img src="img.jpg" id="image">
    </body>
</html>
+4
source share
1 answer

You cannot just pass an element <img>to a function OCRAD().

From the Ocrad.js Documentation :

​​ OCRAD, . [...] image canvas, Context2D ImageData.

:

$(document).ready(function() {
    var $img = $('#image');

    var context = document.createElement('canvas').getContext('2d');
    context.drawImage($img[0], 0, 0);

    var imageData = context.getImageData(0, 0, $img.width(), $img.height());

    var string = OCRAD(imageData);
    alert(string);
});

width height <img>, .


<img> OCRAD(), :

: 5264272 - , . -s DISABLE_EXCEPTION_CATCHING = 0 DISABLE_EXCEPTION_CATCHING = 2 catch.

jQuery OCRAD(), :

:


. : Same Origin Policy, context.getImageData() SecurityError URL ,

+4

All Articles