这是我的代码,提取文字:
try
{
var image = new Bitmap(@"D:\Tessnet2\C#\test2.jpg");
var ocr = new Tesseract();
// ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // If digit only
//@"C:\OCRTest\tessdata" contains the language package, without this the method crash and app breaks
ocr.Init(@"D:\Tessnet2\C#\tessdata", "eng", true);
var result = ocr.DoOCR(image, Rectangle.Empty);
foreach (Word word in result)
Console.WriteLine("{0} : {1}", word.Confidence, word.Text);
Console.ReadLine();
}
catch (Exception exception)
{
}
结果输出:
146: I-18110
47: 88
如何提取文字"Hello"
?
谢谢大家。
答案 0 :(得分:0)
我从以下地方得到了回复:
ocr.Init(@"D:\Tessnet2\C#\tessdata", "eng", true);
到
ocr.Init(@"D:\Tessnet2\C#\tessdata", "eng", false);