tesseract  4.0.0-beta.1-59-g2cc4
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)
 
TESS_LOCAL void tesseract::TessBaseAPI::DetectParagraphs (bool after_text_recognition)
 
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 2531 of file baseapi.cpp.

2536  {
2537  UNICHAR_ID id = tesseract_->unicharset.unichar_to_id(unichar_repr, length);
2538  TBLOB *blob = make_tesseract_blob(baseline, xheight, descender, ascender,
2540  tesseract_->pix_binary());
2541  float threshold;
2542  float best_rating = -100;
2543 
2544 
2545  // Classify to get a raw choice.
2546  BLOB_CHOICE_LIST choices;
2547  tesseract_->AdaptiveClassifier(blob, &choices);
2548  BLOB_CHOICE_IT choice_it;
2549  choice_it.set_to_list(&choices);
2550  for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2551  choice_it.forward()) {
2552  if (choice_it.data()->rating() > best_rating) {
2553  best_rating = choice_it.data()->rating();
2554  }
2555  }
2556 
2557  threshold = tesseract_->matcher_good_threshold;
2558 
2559  if (blob->outlines)
2560  tesseract_->AdaptToChar(blob, id, kUnknownFontinfoId, threshold,
2562  delete blob;
2563 }
TESSLINE * outlines
Definition: blobs.h:377
ADAPT_TEMPLATES AdaptedTemplates
Definition: classify.h:472
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:185
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:858
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, FLOAT32 Threshold, ADAPT_TEMPLATES adaptive_templates)
Definition: adaptmatch.cpp:872
TBLOB * make_tesseract_blob(float baseline, float xheight, float descender, float ascender, bool numeric_mode, Pix *pix)
Definition: baseapi.cpp:2513
Definition: blobs.h:261
double matcher_good_threshold
Definition: classify.h:419
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:207
bool classify_bln_numeric_mode
Definition: classify.h:499
int UNICHAR_ID
Definition: unichar.h:35
UNICHARSET unicharset
Definition: ccutil.h:68
Pix * pix_binary() const

◆ DetectParagraphs()

void tesseract::TessBaseAPI::DetectParagraphs ( bool  after_text_recognition)
protected

Definition at line 2582 of file baseapi.cpp.

2582  {
2583  int debug_level = 0;
2584  GetIntVariable("paragraph_debug_level", &debug_level);
2585  if (paragraph_models_ == NULL)
2587  MutableIterator *result_it = GetMutableIterator();
2588  do { // Detect paragraphs for this block
2590  ::tesseract::DetectParagraphs(debug_level, after_text_recognition,
2591  result_it, &models);
2592  *paragraph_models_ += models;
2593  } while (result_it->Next(RIL_BLOCK));
2594  delete result_it;
2595 }
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel *> *models)
GenericVector< ParagraphModel * > * paragraph_models_
Definition: baseapi.h:863
MutableIterator * GetMutableIterator()
Definition: baseapi.cpp:1244
bool GetIntVariable(const char *name, int *value) const
Definition: baseapi.cpp:278

◆ GetPageRes()

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

Definition at line 853 of file baseapi.h.

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

◆ 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 2566 of file baseapi.cpp.

2566  {
2567  PAGE_RES *page_res = new PAGE_RES(false, block_list,
2569  tesseract_->recog_all_words(page_res, NULL, NULL, NULL, 1);
2570  return page_res;
2571 }
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:858
WERD_CHOICE * prev_word_best_choice_
Definition: wordrec.h:412
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:300

◆ RecognitionPass2()

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

Definition at line 2573 of file baseapi.cpp.

2574  {
2575  if (!pass1_result)
2576  pass1_result = new PAGE_RES(false, block_list,
2578  tesseract_->recog_all_words(pass1_result, NULL, NULL, NULL, 2);
2579  return pass1_result;
2580 }
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:858
WERD_CHOICE * prev_word_best_choice_
Definition: wordrec.h:412
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:300

◆ 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 2668 of file baseapi.cpp.

2675  {
2676  TESS_CHAR_LIST tess_chars;
2677  TESS_CHAR_IT tess_chars_it(&tess_chars);
2678  extract_result(&tess_chars_it, page_res);
2679  tess_chars_it.move_to_first();
2680  int n = tess_chars.length();
2681  int text_len = 0;
2682  *lengths = new int[n];
2683  *costs = new float[n];
2684  *x0 = new int[n];
2685  *y0 = new int[n];
2686  *x1 = new int[n];
2687  *y1 = new int[n];
2688  int i = 0;
2689  for (tess_chars_it.mark_cycle_pt();
2690  !tess_chars_it.cycled_list();
2691  tess_chars_it.forward(), i++) {
2692  TESS_CHAR *tc = tess_chars_it.data();
2693  text_len += (*lengths)[i] = tc->length;
2694  (*costs)[i] = tc->cost;
2695  (*x0)[i] = tc->box.left();
2696  (*y0)[i] = tc->box.bottom();
2697  (*x1)[i] = tc->box.right();
2698  (*y1)[i] = tc->box.top();
2699  }
2700  char *p = *text = new char[text_len];
2701 
2702  tess_chars_it.move_to_first();
2703  for (tess_chars_it.mark_cycle_pt();
2704  !tess_chars_it.cycled_list();
2705  tess_chars_it.forward()) {
2706  TESS_CHAR *tc = tess_chars_it.data();
2707  strncpy(p, tc->unicode_repr, tc->length);
2708  p += tc->length;
2709  }
2710  return n;
2711 }