从tesseract中的图像中获取文本的确切位置 [英] get the exact position of text from image in tesseract

查看:549
本文介绍了从tesseract中的图像中获取文本的确切位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在tesseract中使用GetHOCRText(0)方法我能够在html中检索文本并在webview中呈现html我能够获得文本但图像中文本的位置与输出不同。任何想法都非常有帮助。

Using GetHOCRText(0) method in tesseract I'm able to retrieve the text in html and on presenting the html in webview i'm able get the text but the postion of text in image is different from the output. Any idea is highly helpful.

 tesseract->SetInputName("word");
tesseract->SetOutputName("xyz");
tesseract->Recognize(NULL);


char *utf8Text=tesseract->GetHOCRText(0);

并输出图像

推荐答案

如果你有特定的输出,你应该有一个标签每个字。这些标签应该有class =ocrx_word和name =bbox x1 y1 x2 y2,其中x和y是单词周围边界框的左上角和右下角。我不认为可以自动使用此信息来格式化文本文档 - 需要将像素差异转换为标签/空格的数量。但是,您应该能够在给定位置呈现文本。

If you have the hocr output, you should have a tag for each word. These tags should have class="ocrx_word" and name="bbox x1 y1 x2 y2" where the x and y are the top left and bottom right corner of the bounding box around the word. I don't think it's possible to automatically use this information to format a text document - would require translating pixel differences to number of tabs/spaces. But, you should be able to render text in the given location.

这篇关于从tesseract中的图像中获取文本的确切位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆