在tesseract中查找轮廓的边界框 我正在通过TestSerACT的C++ API部分,找到了从文本中获取每个符号的代码片段。 Pix *image = pixRead("/usr/src/tesseract-3.02/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); 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))); }
现在,如果我们为这个边界框(在tesseract中查找轮廓的边界框 我正在通过TestSerACT的C++ API部分,找到了从文本中获取每个符号的代码片段。 Pix *image = pixRead("/usr/src/tesseract-3.02/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); 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))); },c++,ocr,tesseract,python-tesseract,C++,Ocr,Tesseract,Python Tesseract,现在,如果我们为这个边界框(api->setRectangle)提供了错误的尺寸,它就不会提供所需的文本。那么有没有一种方法可以在tesseract中估算这些维度呢。 链接到相关的源文件:
api->setRectangle
)提供了错误的尺寸,它就不会提供所需的文本。那么有没有一种方法可以在tesseract中估算这些维度呢。
链接到相关的源文件: