在C#中使用MODI读取图像 - 缺少长度为1的数字

时间:2010-03-20 13:18:00

标签: c# ocr modi

我正在构建一个C#应用程序,我试图从gif-image(OCR)中读取文本 - 我使用的是MODI,图像有点像乐透优惠券(行和列中的随机数) 。我现在得到以下代码,读取除单个数字(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;

我无法更改图像的内容,但是我可以使用上面的代码执行任何操作,以便它可以读取单个数字吗?

3 个答案:

答案 0 :(得分:0)

string reult =“”; foreach(在imag.Layout.Words中的MODI.Word文字项目) {    结果+ = worditems.Text + ''; }

答案 1 :(得分:0)

没有找到完美的解决方案,通过在我的照片中添加额外的内容获得了最佳效果,如我上次评论中所述。

答案 2 :(得分:0)

您可以添加以下代码

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);
   }