我想从tesseract中使用ResultIterator
,我在APIExample上使用这样的源代码:
Pix *image = pixRead("test.png");
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));
}
但是我编译时遇到了这个错误:
ocr.cpp: In function ‘int main(int, char**)’:
ocr.cpp:82:34: error: invalid use of incomplete type ‘class tesseract::ResultIterator’
In file included from ocr.cpp:10:0:
/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’
ocr.cpp:83:28: error: invalid use of incomplete type ‘class tesseract::ResultIterator’
In file included from ocr.cpp:10:0:
/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’
ocr.cpp:85:15: error: invalid use of incomplete type ‘class tesseract::ResultIterator’
In file included from ocr.cpp:10:0:
/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’
ocr.cpp:89:20: error: invalid use of incomplete type ‘class tesseract::ResultIterator’
In file included from ocr.cpp:10:0:
/usr/include/tesseract/baseapi.h:83:7: error: forward declaration of ‘class tesseract::ResultIterator’
我的tesseract-ocr-dev
版本为3.02.01-6,版本libtesseract-dev
为3.02.01-6