在iphone中获取tesseract Ocr中的文本位置 [英] Get the text position in tesseract Ocr in iphone

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

问题描述

使用tesseract我已经提取了文本iPhone.现在要提取文本以及xml中的文本位置.我使用GetHocrText来检索HTML中的文本.

Using tesseract I have extract the text iPhone.Now want extract text along with the text position in xml. I uset GetHocrText which retrieves the text in HTML.

例如:-

<span class='ocr_word' id='word_3_28' title="bbox 55 226 123 243">
<span class='ocrx_word' id='xword_3_28' title="x_wconf -5">Beverage</span>
</span>

还有其他方法可以在tesseract OCR中提取XML格式的文本吗?

Is there is any other way to extract text in XML format in tesseract OCR?

感谢adv

Srividya

推荐答案

更好的方法是使用ResultIterator.您可以使用tesseract :: RIL_BLOCK,tesseract :: RIL_PARA,tesseract :: RIL_TEXTLINE,tesseract :: RIL_WORD或tesseract :: RIL_SYMBOL

The better way to do it is to use ResultIterator; you can use tesseract::RIL_BLOCK, tesseract::RIL_PARA, tesseract::RIL_TEXTLINE, tesseract::RIL_WORD, or tesseract::RIL_SYMBOL

来自 https://code.google.com/p/tesseract-ocr/wiki/APIExample :

tesseract::TessBaseAPI api;
// tesseract.Init here
api.SetVariable("save_blob_choices", "T");
// tesseract.SetImage/tesseract.SetRectangle here
api.Recognize(NULL);

tesseract::ResultIterator* ri = api.GetIterator();
tesseract::PageIteratorLevel level = tesseract::RIL_WORD;
if (ri) {
  do {
    const char* word = ri->GetUTF8Text(level);
    float conf = ri->Confidence(level);
    int x1, y1, x2, y2;
    ri->BoundingBox(level, &x1, &y1, &x2, &y2);
    printf("word: '%s';  \tconf: %.2f; BoundingBox: %d,%d,%d,%d;\n",
           word, conf, x1, y1, x2, y2);
    delete[] word;
  } while (ri->Next(level));
}

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

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