2011-02-28 106 views
4

我正在写一个程序,当给出一个低级数学问题的图像(例如98 * 13)应该能够输出答案。数字是黑色的,背景是白色的。 不是一个验证码,只是一个数学问题的图像。哪个库用于从图像中提取文本?

数学问题只会有两个数字和一个运算符,而该运算符只会是+, - ,*或/。

显然,我知道如何做计算;)我只是不知道如何去从图像中获取文本。

一个免费的图书馆将是理想的...虽然如果我必须自己写代码,我可能可以管理。

+0

你是Google吗? – RQDQ 2011-02-28 19:32:03

+1

是的。我找不到任何适用的... – Entity 2011-02-28 19:37:51

回答

1

你需要OCR使用C++谷歌Tessaract OCR lib中关于这个职位。 Google提供免费的Tesseract图书馆,但它是C代码。您可以在C++/CLI项目中使用并通过.NET进行访问。

这篇文章对识别号码的一些信息(数独,但你的问题是相似的)

http://sudokugrab.blogspot.com/2009/07/how-does-it-all-work.html

0

您可以在VISAUL工作室和提取使用Microsoft Office Document Imaging中(Interop.MODI.dll)图片

Document modiDocument = new Document(); 
modiDocument.Create(filePath); 
modiDocument.OCR(MiLANGUAGES.miLANG_ENGLISH); 
MODI.Image modiImage = (modiDocument.Images[0] as MODI.Image); 
string extractedText = modiImage.Layout.Text; 
modiDocument.Close(); 
return extractedText; 
1

对于从图像提取词的文字,我用的是最准确的开源OCR引擎:正方体。可用here或直接在你的包NuGet。

这是我在C#中的函数,它从图像中提取文字sourceFilePath。将EngineMode设置为TesseractAndCube;它会检测到比其他选项更多的单词。

var path = "YourSolutionDirectoryPath"; 
using (var engine = new TesseractEngine(path + Path.DirectorySeparatorChar + "tessdata", "fra", EngineMode.TesseractAndCube)) 
{ 
    using (var img = Pix.LoadFromFile(sourceFilePath)) 
    { 
     using (var page = engine.Process(img)) 
     { 
      var text = page.GetText(); 
      // text variable contains a string with all words found 
     } 
    } 
} 

我希望有所帮助。

0

这里是C#一些有用的示例代码:

  1. 使用正方体:免费开源的OCR应用程序对Windows桌面 - 一个现代化的GUI前端为正方体OCR引擎。该应用程序还包括用于读取和OCR'ing PDF文件的支持:https://github.com/A9T9/Free-Ocr-Windows-Desktop

  2. 使用微软OCR:对于Windows应用商店免费开源的OCR应用程序 - 一个现代化的GUI前端为微软OCR库。该应用程序还包括读取和OCR'PDF文件的支持:https://github.com/A9T9/Free-OCR-Software