* **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"
https://github.com/tesseract-ocr/tesseract/wiki/APIExample

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
![white-space](https://user-images.githubusercontent.com/698547/45849852-8c796280-bce8-11e8-9b06-196d8909d297.png)


Is there any API to check the hasNext()?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/359b2d1f-359e-4d26-8224-06747e62ac5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to