根据我的经验,OCR库往往只输出图像内,但没有找到文本,其中文本被发现.是否有一个OCR库可以输出图像中找到的单词以及x, y, width, height
找到这些单词的坐标()?
And*_*ash 25
大多数商业OCR引擎将返回单词和字符坐标位置,但您必须使用其SDK来提取信息.即使是Tesseract OCR也会返回位置信息,但这并不容易.版本3.01将变得更容易,但仍在处理DLL接口.
不幸的是,大多数免费的OCR程序以其基本形式使用Tesseract OCR,它们只报告原始ASCII结果.
www.transym.com - Transym OCR - 输出坐标.www.rerecognition.com - Kasmos引擎返回坐标.
此外,Caere Omnipage,Mitek,Abbyy,Charactell也回归角色.
Ben*_*ker 14
我正在使用TessNet(一个Tesseract C#包装器),我正在使用以下代码获得单词坐标:
TextWriter tw = new StreamWriter(@"U:\user files\bwalker\ocrTesting.txt");
Bitmap image = new Bitmap(@"u:\user files\bwalker\2849257.tif");
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
// If digit only
ocr.SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,$-/#&=()\"':?");
// To use correct tessdata
ocr.Init(@"C:\Users\bwalker\Documents\Visual Studio 2010\Projects\tessnetWinForms\tessnetWinForms\bin\Release\", "eng", false);
List<tessnet2.Word> result = ocr.DoOCR(image, System.Drawing.Rectangle.Empty);
string Results = "";
foreach (tessnet2.Word word in result)
{
Results += word.Confidence + ", " + word.Text + ", " +word.Top+", "+word.Bottom+", "+word.Left+", "+word.Right+"\n";
}
using (StreamWriter writer = new StreamWriter(@"U:\user files\bwalker\ocrTesting2.txt", true))
{
writer.WriteLine(Results);//+", "+word.Top+", "+word.Bottom+", "+word.Left+", "+word.Right);
writer.Close();
}
MessageBox.Show("Completed");
Run Code Online (Sandbox Code Playgroud)
您可以像这样hocr
在tesseract 中使用“configfile” :
tesseract syllabus-page1.jpg syllabus-page1 hocr
Run Code Online (Sandbox Code Playgroud)
这将输出一个主要为 HTML5 的文档,其中包含以下元素:
<div class='ocr_page' id='page_1' title='image "syllabus-page1.jpg"; bbox 0 0 2531 3272; ppageno 0'>
<div class="ocr_carea" id="block_1_4" title="bbox 265 1183 2147 1778">
<p class="ocr_par" dir="ltr" id="par_1_8" title="bbox 274 1305 655 1342">
<span class="ocr_line" id="line_1_14" title="bbox 274 1305 655 1342; baseline -0.005 0; x_size 46.378059; x_descenders 10.378059; x_ascenders 12">
<span class="ocrx_word" id="word_1_78" title="bbox 274 1307 386 1342; x_wconf 90" lang="eng" dir="ltr">needs</span>
<span class="ocrx_word" id="word_1_79" title="bbox 402 1318 459 1342; x_wconf 90" lang="eng" dir="ltr">are</span>
<span class="ocrx_word" id="word_1_80" title="bbox 474 1305 655 1341; x_wconf 86" lang="eng" dir="ltr">different:</span>
</span>
</p>
...
</div>
...
</div>
Run Code Online (Sandbox Code Playgroud)
虽然我很确定这不是您应该如何使用 XML,但我发现它比深入研究 tesseract API 更容易。
PS 我意识到有几个评论和答案暗示了这个解决方案,但没有一个真正展示如何使用该hocr
选项或描述您从中获得的输出。
归档时间: |
|
查看次数: |
19881 次 |
最近记录: |