using MODI in C# to read image - numbers with a length of 1 is missing
I am about building an C#-application in which I am trying to read text from an gif-image (OCR) - I am using MODI and the images are a bit like a lotto coupon (random numbers in rows and columns). I now got the following code which read all numbers except single numbers (1, 2, 3...)
MODI.Document 开发者_如何学编程objModi = new MODI.Document();
objModi.Create("C:\\image.gif");
objModi.OCR(MODI.MiLANGUAGES.miLANG_DANISH, true, true);
MODI.Image image = (MODI.Image)objModi.Images[0];
MODI.Layout layout = image.Layout;
I cannot change the content of the image but can I do anything with the above code so it can read the single numbers?
string reult=""; foreach(MODI.Word worditems in imag.Layout.Words) { result+=worditems.Text+','; }
Did not find a perfect solution, got the best result by adding extra content to my picture as described in my last comment.
You can add the follwoing code
numofwords = layout.NumWords;
for (int l = 0; l < numofwords; l++)
    {
        word = (MODI.Word)layout.Words[l];
        for (int j = 0; j < word.Rects.Count; j++)
        {
            MODI.MiRect rect = (MODI.MiRect)word.Rects[j];
            if (j == 0)
            {
                top = rect.Top;
            }
            if (height == 0 || height < (rect.Bottom - rect.Top))
                height = rect.Bottom - rect.Top;
            width = rect.Right - rect.Left;
            right = rect.Left + width;
            top = rect.Top;
            left = rect.Left;
        }
        OCRDocWord ocrword = new OCRDocWord(top, left, width, height, word.Text);
        width = 0;
        wordlist.Add(ocrword);
   }
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论