Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Web OCR

Last post 03 Nov 2008, 11:59 AM by Elaine. 3 replies.
Sort Posts: Previous Next
  •  21 Oct 2008, 3:38 AM 16215

    Web OCR

    Hi, i want to perform an OCR process for the selection text in WebAnnotationViewer1 using RectangleData.
    How can i do it? I'm currently test out the following code during OnAnnotationRightClicked event but it return empty string to me.

    WebAnnotationViewer1.RemoteInvoke("GetWordAtPoint", new Array(x, y));

    Any sample for the Web OCR using RectangleData?
    Thanks.


     

     

  •  21 Oct 2008, 1:08 PM 16228 in reply to 16215

    Re: Web OCR

  •  21 Oct 2008, 9:59 PM 16242 in reply to 16228

    Re: Web OCR

    Hi, i already downloaded that program.


    Question 1
    For the function below, is that 'alertWord' will called first, then follow by 'GetWordAtPoint'? For the x, y, is it the
    point i clicked on? And how if i wan to pass in the rectangle point?

       var go = function() {
            WebAnnotationViewer1.RemoteInvoked = alertWord;
            WebAnnotationViewer1.RemoteInvoke("GetWordAtPoint", new Array(x, y));
       }


    Question 2
    In GetWordAtPoint function, may i know what is w.Bounds.Contains(new Point(x, y)) doing? And i not understand why everytime i will get the same result for r value for OcrTextRegion, eventhough the image i loaded into WebAnnotationViewer1 is different. What i need to check out to solve this issues?

            [RemoteInvokable]
            public string GetWordAtPoint(int x, int y)
            {
                OcrPage p = (OcrPage)Application["ocrPage"];

                string val = "";

                foreach (OcrTextRegion r in p.Regions)
                    foreach (OcrLine l in r.Lines)
                        foreach (OcrWord w in l.Words)
                            if (w.Bounds.Contains(new Point(x, y)))
                                val = w.Text;

                // This is not the best way to escape single quotes.
                // It should be much more robust than this.
                return val.Replace("'", "~~");
            }


    Question 3
    When should i call up this two events? Can i called it during OpenImageCallBack() function? Or must called during OnPageLoad() function?

    WebAnnotationViewer1.RemoteInvoked = showPanel;
    WebAnnotationViewer1.RemoteInvoke("OcrImage", new Array());

     

    function OpenImageCallBack(){
     WebAnnotationViewer1.RemoteInvoked = function(){};
     WebThumbnailViewer1.OpenUrl(WebAnnotationViewer1.getReturnValue());
     Label_FileName.innerHTML = WebThumbnailViewer1.getUrl();
     WebAnnotationViewer1.RemoteInvoked = showPanel;
     WebAnnotationViewer1.RemoteInvoke("OcrImage", new Array());
    }


    Question 4
    The sample source code not support in IE7? I test out the same copy of source code, it run fine in IE6, but in IE7 it return empty string when i do the click.


     Thanks.

  •  03 Nov 2008, 11:59 AM 16450 in reply to 16242

    Re: Web OCR

    Attachment: WebOCR.zip

    Greetings!

    To answer your questions...

    1.  A function that is set to the RemoteInvoked (note the past tense) property of the WebImageViewer or WebAnnotationViewer is run AFTER the RemoteInvoke Call.   So, in this example, SetWordAtPoint runs, then alertWord is called when the server-side processing is finished.

    2.  w.Bounds.Contains(new Point(x, y))

    Each OcrWord w that is return contains a bounding rectangle.  If the point you clicked is inside that rectangle, the OcrWord is returned as the correct word.

    This demo was not set up for selection rectangles -- only single clicks.  The OcrTextRegion will always be the entire page in this example, as the initial Recognize was not done with any sort of region rectangle.

    3.  The OcrImage function should be called in the OnPageLoad function.  It is an initializing function you only want to call once.

    4.  I am not having issues with IE7.  However, I've attached a different demo for you -- one that incorporates selecting the text you want recognized with a rectangle, and only performing OCR on the region specified.


    Elaine Gorham
    Developer Support Supervisor
    Atalasoft, Inc.
View as RSS news feed in XML