All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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

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

2361  {
2362  UNICHAR_ID id = tesseract_->unicharset.unichar_to_id(unichar_repr, length);
2363  TBLOB *blob = make_tesseract_blob(baseline, xheight, descender, ascender,
2365  tesseract_->pix_binary());
2366  float threshold;
2367  float best_rating = -100;
2368 
2369 
2370  // Classify to get a raw choice.
2371  BLOB_CHOICE_LIST choices;
2372  tesseract_->AdaptiveClassifier(blob, &choices);
2373  BLOB_CHOICE_IT choice_it;
2374  choice_it.set_to_list(&choices);
2375  for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2376  choice_it.forward()) {
2377  if (choice_it.data()->rating() > best_rating) {
2378  best_rating = choice_it.data()->rating();
2379  }
2380  }
2381 
2382  threshold = tesseract_->matcher_good_threshold;
2383 
2384  if (blob->outlines)
2385  tesseract_->AdaptToChar(blob, id, kUnknownFontinfoId, threshold,
2387  delete blob;
2388 }
Definition: blobs.h:261
bool classify_bln_numeric_mode
Definition: classify.h:500
const UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:194
double matcher_good_threshold
Definition: classify.h:420
UNICHARSET unicharset
Definition: ccutil.h:72
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:185
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, FLOAT32 Threshold, ADAPT_TEMPLATES adaptive_templates)
Definition: adaptmatch.cpp:886
int UNICHAR_ID
Definition: unichar.h:33
TBLOB * make_tesseract_blob(float baseline, float xheight, float descender, float ascender, bool numeric_mode, Pix *pix)
Definition: baseapi.cpp:2338
Pix * pix_binary() const
TESSLINE * outlines
Definition: blobs.h:377
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:833
ADAPT_TEMPLATES AdaptedTemplates
Definition: classify.h:473
void tesseract::TessBaseAPI::DetectParagraphs ( bool  after_text_recognition)
protected

Definition at line 2407 of file baseapi.cpp.

2407  {
2408  int debug_level = 0;
2409  GetIntVariable("paragraph_debug_level", &debug_level);
2410  if (paragraph_models_ == NULL)
2412  MutableIterator *result_it = GetMutableIterator();
2413  do { // Detect paragraphs for this block
2415  ::tesseract::DetectParagraphs(debug_level, after_text_recognition,
2416  result_it, &models);
2417  *paragraph_models_ += models;
2418  } while (result_it->Next(RIL_BLOCK));
2419  delete result_it;
2420 }
bool GetIntVariable(const char *name, int *value) const
Definition: baseapi.cpp:228
GenericVector< ParagraphModel * > * paragraph_models_
Definition: baseapi.h:842
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA * > *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel * > *models)
#define NULL
Definition: host.h:144
MutableIterator * GetMutableIterator()
Definition: baseapi.cpp:1288
TESS_LOCAL const PAGE_RES* tesseract::TessBaseAPI::GetPageRes ( ) const
inlineprotected

Definition at line 831 of file baseapi.h.

831  {
832  return page_res_;
833  };
PAGE_RES * page_res_
The page-level data.
Definition: baseapi.h:844
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 2391 of file baseapi.cpp.

2391  {
2392  PAGE_RES *page_res = new PAGE_RES(false, block_list,
2394  tesseract_->recog_all_words(page_res, NULL, NULL, NULL, 1);
2395  return page_res;
2396 }
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:287
WERD_CHOICE * prev_word_best_choice_
Definition: wordrec.h:416
#define NULL
Definition: host.h:144
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:833
PAGE_RES * tesseract::TessBaseAPI::RecognitionPass2 ( BLOCK_LIST *  block_list,
PAGE_RES pass1_result 
)
protected

Definition at line 2398 of file baseapi.cpp.

2399  {
2400  if (!pass1_result)
2401  pass1_result = new PAGE_RES(false, block_list,
2403  tesseract_->recog_all_words(pass1_result, NULL, NULL, NULL, 2);
2404  return pass1_result;
2405 }
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:287
WERD_CHOICE * prev_word_best_choice_
Definition: wordrec.h:416
#define NULL
Definition: host.h:144
Tesseract * tesseract_
The underlying data object.
Definition: baseapi.h:833
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 2493 of file baseapi.cpp.

2500  {
2501  TESS_CHAR_LIST tess_chars;
2502  TESS_CHAR_IT tess_chars_it(&tess_chars);
2503  extract_result(&tess_chars_it, page_res);
2504  tess_chars_it.move_to_first();
2505  int n = tess_chars.length();
2506  int text_len = 0;
2507  *lengths = new int[n];
2508  *costs = new float[n];
2509  *x0 = new int[n];
2510  *y0 = new int[n];
2511  *x1 = new int[n];
2512  *y1 = new int[n];
2513  int i = 0;
2514  for (tess_chars_it.mark_cycle_pt();
2515  !tess_chars_it.cycled_list();
2516  tess_chars_it.forward(), i++) {
2517  TESS_CHAR *tc = tess_chars_it.data();
2518  text_len += (*lengths)[i] = tc->length;
2519  (*costs)[i] = tc->cost;
2520  (*x0)[i] = tc->box.left();
2521  (*y0)[i] = tc->box.bottom();
2522  (*x1)[i] = tc->box.right();
2523  (*y1)[i] = tc->box.top();
2524  }
2525  char *p = *text = new char[text_len];
2526 
2527  tess_chars_it.move_to_first();
2528  for (tess_chars_it.mark_cycle_pt();
2529  !tess_chars_it.cycled_list();
2530  tess_chars_it.forward()) {
2531  TESS_CHAR *tc = tess_chars_it.data();
2532  strncpy(p, tc->unicode_repr, tc->length);
2533  p += tc->length;
2534  }
2535  return n;
2536 }