* **Tesseract Version**: 3.5.0 and 4.0
* **Platform**: mac & ubuntu 18.04
I am iterating over recognize api as suggested here. "Result iterator example"
Pix *image = pixRead("/usr/src/tesseract/testing/phototest.tif");
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
api->Init(NULL, "eng");
api->SetImage(image);
api->Recognize(0);
tesseract::ResultIterator* ri = api->GetIterator();
tesseract::PageIteratorLevel level = tesseract::RIL_WORD;
if (ri != 0) {
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));
}
it seems we do before calling next. If I am calling next first, it will skip over the first detections.
Unfortunately when I get this error,
**'NoneType' object is not iterable issue**
When there is no detection.
Here is the code in python-tesserocr
if (iterator != None):
next = True
while (next):
x,y,right,bottom = iterator.BoundingBox(level)
next = iterator.Next(level)
it throws an error on iterator.BoundingBox saying that the iterator is empty.
If I call "next = iterator.Next(level)" first, it avoids that error, but it also skip over the first detection
Here is the image, just the whitespace image
Is there any API to check the hasNext()?
Thanks