character/word [OCR 应用] 的坐标

Coordinates of a character/word [OCR app]

所以基本上,我正在创建一个 android 应用程序(使用 tesseract 和 OpenCV),当在预处理和扫描步骤后给出一个词时,在该词周围绘制一个矩形 - 基本上 "finds" 这个词并标记它。但是我想知道如何获取角色的坐标?或者至少一句话?我有每条线的坐标,但坐标不是相对于 "main-picture",而是我拥有的 "text-blocks" 的唯一坐标。也许有人 has/knows explanation/tutorial 或某种关于如何找到 word/character 坐标的信息。非常感谢。

此示例代码取自 tesseract 的 API Examples Wiki 页面,应该有助于: APIExamples

关注这两行: int x1, y1, x2, y2; ri->BoundingBox(level, &x1, &y1, &x2, &y2);

Pix *image = pixRead("/usr/src/tesseract/testing/phototest.tif");
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
api->Init(NULL, "eng");
api->SetImage(image);
api->SetVariable("save_blob_choices", "T");
api->SetRectangle(37, 228, 548, 31);
api->Recognize(NULL);

tesseract::ResultIterator* ri = api->GetIterator();
tesseract::PageIteratorLevel level = tesseract::RIL_SYMBOL;
if(ri != 0) {
  do {
      const char* symbol = ri->GetUTF8Text(level);
      float conf = ri->Confidence(level);
      int x1, y1, x2, y2;
      ri->BoundingBox(level, &x1, &y1, &x2, &y2);
      if(symbol != 0) {
          printf("symbol %s, conf: %f", symbol, conf);
          bool indent = false;
          tesseract::ChoiceIterator ci(*ri);
          do {
              if (indent) printf("\t\t ");
              printf("\t- ");
              const char* choice = ci.GetUTF8Text();
              printf("%s conf: %f\n", choice, ci.Confidence());
              indent = true;
          } while(ci.Next());
      }
      printf("---------------------------------------------\n");
      delete[] symbol;
  } while((ri->Next(level)));
}