【问题标题】:Tesseract command line interface: Get recognition confidence per characterTesseract 命令行界面:获取每个字符的识别置信度
【发布时间】:2017-06-20 08:46:59
【问题描述】:

使用 Tesseract C API 时,可以迭代识别的字符,获取它们的边界框和识别置信度。

我已经发现了如何使用 Tesseract CLI 获取边界框,这是通过在命令末尾添加 ma​​kebox 来完成的。问题是它不包含识别置信度。

有没有办法告诉 Tesseract CLI 也输出每个字符的置信度?

【问题讨论】:

  • 您的问题找到解决方案了吗?

标签: tesseract


【解决方案1】:

以下是来自tesseract github 的 API 示例。

GetComponentImages 示例

Pix *image = pixRead("/usr/src/tesseract/testing/phototest.tif");
  tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
  api->Init(NULL, "eng");
  api->SetImage(image);
  Boxa* boxes = api->GetComponentImages(tesseract::RIL_TEXTLINE, true, NULL, NULL);
  printf("Found %d textline image components.\n", boxes->n);
  for (int i = 0; i < boxes->n; i++) {
    BOX* box = boxaGetBox(boxes, i, L_CLONE);
    api->SetRectangle(box->x, box->y, box->w, box->h);
    char* ocrResult = api->GetUTF8Text();
    int conf = api->MeanTextConf();
    fprintf(stdout, "Box[%d]: x=%d, y=%d, w=%d, h=%d, confidence: %d, text: %s",
                    i, box->x, box->y, box->w, box->h, conf, ocrResult);
  }

fprintf() 包含用于打印框和置信信息。

希望对您有所帮助。

编辑:

要从 CLI 获取置信度 (conf) 值和边界框 (lefttopwidthheight),请将 tesseract 输出设置为 tsv 格式。以下是输出文件名为test.tsv的示例命令。

C:\> tesseract test.tif test -l eng tsv

这是 Excel 查看的tsv 输出文件。

您可以参考此tesseract wiki 了解更多信息。

【讨论】:

  • 感谢您提供 API 示例。当我在 Windows 中工作时,我需要一些方法来使用 CLI 来完成它。在 Windows 中编译 Tesseract 以使用它的 API 真是令人头疼
  • @SomethingSomething 同意让tesseract 服从并不容易。使用 CLI command 更新的答案以简化 shell 命令的执行,如果适用于您的情况,希望对您有所帮助。请检查。
  • @thewayweare,谢谢。 TSV 的问题在于它只输出单词置信度而不是单个字符置信度。在 Tesseract API 中,使用迭代器级别,您也可以获得每个字符的置信度,这正是我所需要的
猜你喜欢
  • 2013-03-27
  • 1970-01-01
  • 2013-03-18
  • 2014-01-16
  • 2014-01-09
  • 2012-03-26
  • 2017-06-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多