你好谁能给我一个测试 Tesseract OCR 的简单例子
最好使用 C#。
我尝试了发现 here 的演示。
我下载了英文数据集,解压在C盘。并修改代码如下:
string path = @"C:\pic\mytext.jpg";
Bitmap image = new Bitmap(path);
Tesseract ocr = new Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // If digit only
ocr.Init(@"C:\tessdata\", "eng", false); // To use correct tessdata
List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
foreach (tessnet2.Word word in result)
Console.WriteLine("{0} : {1}", word.Confidence, word.Text);
不幸的是代码不起作用。程序死于“ocr.Init(...”行。即使使用 try-catch 我什至无法获得异常。
我能够运行 vietocr !但这对我来说是一个非常大的项目。我需要一个像上面这样的简单示例。
最佳答案
好的。我在这里找到了解决方案 tessnet2 fails to load Adam 给出的 Ans
显然我使用了错误版本的 tessdata。我在关注 the source page直观的指令,并导致了问题。
它说
Quick Tessnet2 usage
Download binary here, add a reference of the assembly Tessnet2.dll to your .NET project.
Download language data definition file here and put it in tessdata directory. Tessdata directory and your exe must be in the same directory.
下载二进制文件后,当您点击链接下载语言文件时,有很多语言文件。但它们都不是正确的版本。您需要选择所有版本并转到下一页以获得正确的版本 (tesseract-2.00.eng)!他们应该将下载二进制链接更新到版本 3,或者将版本 2 语言文件放在第一页上。或者至少大胆提及这个版本问题是个大问题!
总之我找到了。 谢谢大家。
关于c# - Tesseract OCR 简单示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16598390/