tesseract  4.1.3
ocropus add-ons

Functions

TESS_LOCAL void tesseract::TessBaseAPI::AdaptToCharacter (const char *unichar_repr, int length, float baseline, float xheight, float descender, float ascender)
 
TESS_LOCAL PAGE_REStesseract::TessBaseAPI::RecognitionPass1 (BLOCK_LIST *block_list)
 
TESS_LOCAL PAGE_REStesseract::TessBaseAPI::RecognitionPass2 (BLOCK_LIST *block_list, PAGE_RES *pass1_result)
 
static TESS_LOCAL int tesseract::TessBaseAPI::TesseractExtractResult (char **text, int **lengths, float **costs, int **x0, int **y0, int **x1, int **y1, PAGE_RES *page_res)
 
TESS_LOCAL const PAGE_REStesseract::TessBaseAPI::GetPageRes () const
 

Detailed Description

Function Documentation

◆ AdaptToCharacter()

void tesseract::TessBaseAPI::AdaptToCharacter ( const char *  unichar_repr,
int  length,
float  baseline,
float  xheight,
float  descender,
float  ascender 
)
protected

Adapt to recognize the current image as the given character. The image must be preloaded and be just an image of a single character.

Adapt to recognize the current image as the given character. The image must be preloaded into pix_binary_ and be just an image of a single character.

Definition at line 2428 of file baseapi.cpp.

2433  {
2434  UNICHAR_ID id = tesseract_->unicharset.unichar_to_id(unichar_repr, length);
2435  TBLOB *blob = make_tesseract_blob(baseline, xheight, descender, ascender,
2437  tesseract_->pix_binary());
2438  float threshold;
2439  float best_rating = -100;
2440 
2441 
2442  // Classify to get a raw choice.
2443  BLOB_CHOICE_LIST choices;
2444  tesseract_->AdaptiveClassifier(blob, &choices);
2445  BLOB_CHOICE_IT choice_it;
2446  choice_it.set_to_list(&choices);
2447  for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2448  choice_it.forward()) {
2449  if (choice_it.data()->rating() > best_rating) {
2450  best_rating = choice_it.data()->rating();
2451  }
2452  }
2453 
2454  threshold = tesseract_->matcher_good_threshold;
2455 
2456  if (blob->outlines)
2457  tesseract_->AdaptToChar(blob, id, kUnknownFontinfoId, threshold,
2459  delete blob;
2460 }
int UNICHAR_ID
Definition: unichar.h:34
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, float Threshold, ADAPT_TEMPLATES adaptive_templates)
Definition: adaptmatch.cpp:853
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:191
Pix * pix_binary() const
Definition: blobs.h:284
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:888
TESSLINE * outlines
Definition: blobs.h:400
double matcher_good_threshold
Definition: classify.h:456
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:210
ADAPT_TEMPLATES AdaptedTemplates
Definition: classify.h:515
bool classify_bln_numeric_mode
Definition: classify.h:508
UNICHARSET unicharset
Definition: ccutil.h:73

◆ GetPageRes()

TESS_LOCAL const PAGE_RES* tesseract::TessBaseAPI::GetPageRes ( ) const
inlineprotected

Definition at line 883 of file baseapi.h.

883 { return page_res_; }
PAGE_RES * page_res_
The page-level data.
Definition: baseapi.h:895

◆ RecognitionPass1()

PAGE_RES * tesseract::TessBaseAPI::RecognitionPass1 ( BLOCK_LIST *  block_list)
protected

Recognize text doing one pass only, using settings for a given pass.

Definition at line 2463 of file baseapi.cpp.

2463  {
2464  auto *page_res = new PAGE_RES(false, block_list,
2466  tesseract_->recog_all_words(page_res, nullptr, nullptr, nullptr, 1);
2467  return page_res;
2468 }
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
Definition: control.cpp:302
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:888
WERD_CHOICE * prev_word_best_choice_
Definition: wordrec.h:476

◆ RecognitionPass2()

PAGE_RES * tesseract::TessBaseAPI::RecognitionPass2 ( BLOCK_LIST *  block_list,
PAGE_RES pass1_result 
)
protected

Definition at line 2470 of file baseapi.cpp.

2471  {
2472  if (!pass1_result)
2473  pass1_result = new PAGE_RES(false, block_list,
2475  tesseract_->recog_all_words(pass1_result, nullptr, nullptr, nullptr, 2);
2476  return pass1_result;
2477 }
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
Definition: control.cpp:302
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:888
WERD_CHOICE * prev_word_best_choice_
Definition: wordrec.h:476

◆ TesseractExtractResult()

int tesseract::TessBaseAPI::TesseractExtractResult ( char **  text,
int **  lengths,
float **  costs,
int **  x0,
int **  y0,
int **  x1,
int **  y1,
PAGE_RES page_res 
)
staticprotected

Extract the OCR results, costs (penalty points for uncertainty), and the bounding boxes of the characters.

Definition at line 2554 of file baseapi.cpp.

2561  {
2562  TESS_CHAR_LIST tess_chars;
2563  TESS_CHAR_IT tess_chars_it(&tess_chars);
2564  extract_result(&tess_chars_it, page_res);
2565  tess_chars_it.move_to_first();
2566  int n = tess_chars.length();
2567  int text_len = 0;
2568  *lengths = new int[n];
2569  *costs = new float[n];
2570  *x0 = new int[n];
2571  *y0 = new int[n];
2572  *x1 = new int[n];
2573  *y1 = new int[n];
2574  int i = 0;
2575  for (tess_chars_it.mark_cycle_pt();
2576  !tess_chars_it.cycled_list();
2577  tess_chars_it.forward(), i++) {
2578  TESS_CHAR *tc = tess_chars_it.data();
2579  text_len += (*lengths)[i] = tc->length;
2580  (*costs)[i] = tc->cost;
2581  (*x0)[i] = tc->box.left();
2582  (*y0)[i] = tc->box.bottom();
2583  (*x1)[i] = tc->box.right();
2584  (*y1)[i] = tc->box.top();
2585  }
2586  char *p = *text = new char[text_len];
2587 
2588  tess_chars_it.move_to_first();
2589  for (tess_chars_it.mark_cycle_pt();
2590  !tess_chars_it.cycled_list();
2591  tess_chars_it.forward()) {
2592  TESS_CHAR *tc = tess_chars_it.data();
2593  strncpy(p, tc->unicode_repr, tc->length);
2594  p += tc->length;
2595  }
2596  return n;
2597 }