1

我正在使用 tessnet2 从 .tif 图像中获取文本。例如,我想从图像中获取十进制“700”,但我得到了这个:“Mupann”我正在使用法语 tessdata 这里我正在使用的代码:

 ocr.SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,$-/#&=()\':?")
        ocr.Init(Application.StartupPath & "\tessdata", "fra", False)
        Dim result As List(Of tessnet2.Word) = ocr.DoOCR(captureTIF, Rectangle.Empty)

        For Each word As tessnet2.Word In result
            MsgBox(word.Confidence & " >> " & word.Text)
            RichTextBox1.Text &= word.Confidence & word.Text
        Next

谢谢

4

1 回答 1

0

我不知道这对你的情况是否有帮助。但是当我使用 TessNet2 时,我使用了一个布尔函数来确定某些单词。您会看到我要查找的单词有多个案例。我敢肯定,这不是最有效的方式,但这是一种方式。

public Boolean isPageABSTRACTING(List<tessnet2.Word> wordList)
        {

            for (int i = 0; i < wordList.Count; i++) //scan through words
            {
                if ((wordList[i].Text == "Abstracting" || wordList[i].Text == "abstracting" || wordList[i].Text == "abstractmg" || wordList[i].Text == "Abstractmg" && wordList[i].Confidence >= 50) && (wordList[i + 1].Text == "Service" || wordList[i + 1].Text == "service" || wordList[i + 1].Text == "5ervice" && wordList[i + 1].Confidence >= 50) && (wordList[i + 2].Text == "Ordered" || wordList[i + 2].Text == "ordered" && wordList[i + 2].Confidence >= 50)) //find 1st tier check
                {
                    for (int j = 0; j < wordList.Count; j++) //scan through words again
                    {
                        if ((wordList[j].Text == "Due" || wordList[j].Text == "Oue" && wordList[j].Confidence >= 50) && (wordList[j + 1].Text == "Date" || wordList[j + 1].Text == "Oate" && wordList[j + 1].Confidence >= 50) && (wordList[j + 2].Text == "&" && wordList[j + 2].Confidence >= 50)) //find 2nd tier check
                        {
                            for (int h = 0; h < wordList.Count; h++) //scan through words again
                            {
                                if ((wordList[h].Text == "Additional" || wordList[h].Text == "additional" && wordList[h].Confidence >= 50) && (wordList[h + 1].Text == "comments" || wordList[h + 1].Text == "Comments" && wordList[h + 1].Confidence >= 50) && (wordList[h + 2].Text == "about" || wordList[h + 2].Text == "About" && wordList[h + 2].Confidence >= 50) && (wordList[h + 3].Text == "this" || wordList[h + 3].Text == "This" && wordList[h + 3].Confidence >= 50)) //find 3rd tier check
                                {
                                    return true;
                                }
                            }
                        }
                    }
                }
            }

            return false;
        }
于 2013-07-11T16:16:47.730 回答