How to use TessBaseAPI::GetUnichar() safely?

13 views
Skip to first unread message

db4

unread,
Jul 1, 2019, 6:13:23 AM7/1/19
to tesseract-ocr
I'm trying to get the actual charset loaded by Tesseract from a .traineddata file. I can call TessBaseAPI::GetUnichar(id++) in a loop but how to find what the maximum acceptable id is? TessBaseAPI::GetUnichar() implementation is just
 
const char* TessBaseAPI::GetUnichar(int unichar_id) {
 return tesseract_->unicharset.id_to_unichar(unichar_id);
}

that in turn calls
  
const char* UNICHARSET::id_to_unichar(UNICHAR_ID id) const {
 if (id == INVALID_UNICHAR_ID) {
  return INVALID_UNICHAR;
 }
 ASSERT_HOST(id < this->size());
 return unichars[id].representation;
}

I assume it will crash if id is out of bounds. And UNICHARSET::size() is not exposed via TessBaseAPI. Any idea how one could use TessBaseAPI::GetUnichar() to get chars known to Tesseract?
Reply all
Reply to author
Forward
0 new messages