tesseract 4.1.1
Loading...
Searching...
No Matches
tesseractclass.h
Go to the documentation of this file.
1
2// File: tesseractclass.h
3// Description: The Tesseract class. It holds/owns everything needed
4// to run Tesseract on a single language, and also a set of
5// sub-Tesseracts to run sub-languages. For thread safety, *every*
6// global variable goes in here, directly, or indirectly.
7// This makes it safe to run multiple Tesseracts in different
8// threads in parallel, and keeps the different language
9// instances separate.
10// Author: Ray Smith
11//
12// (C) Copyright 2008, Google Inc.
13// Licensed under the Apache License, Version 2.0 (the "License");
14// you may not use this file except in compliance with the License.
15// You may obtain a copy of the License at
16// http://www.apache.org/licenses/LICENSE-2.0
17// Unless required by applicable law or agreed to in writing, software
18// distributed under the License is distributed on an "AS IS" BASIS,
19// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20// See the License for the specific language governing permissions and
21// limitations under the License.
22//
24
25#ifndef TESSERACT_CCMAIN_TESSERACTCLASS_H_
26#define TESSERACT_CCMAIN_TESSERACTCLASS_H_
27
28#include <cstdint> // for int16_t, int32_t, uint16_t
29#include <cstdio> // for FILE
30#include "allheaders.h" // for pixDestroy, pixGetWidth, pixGetHe...
31#include "control.h" // for ACCEPTABLE_WERD_TYPE
32#include "debugpixa.h" // for DebugPixa
33#include "devanagari_processing.h" // for ShiroRekhaSplitter
34#ifndef DISABLED_LEGACY_ENGINE
35#include "docqual.h" // for GARBAGE_LEVEL
36#endif
37#include "genericvector.h" // for GenericVector, PointerVector
38#include "pageres.h" // for WERD_RES (ptr only), PAGE_RES (pt...
39#include "params.h" // for BOOL_VAR_H, BoolParam, DoubleParam
40#include "points.h" // for FCOORD
41#include "publictypes.h" // for OcrEngineMode, PageSegMode, OEM_L...
42#include "ratngs.h" // for ScriptPos, WERD_CHOICE (ptr only)
43#include "strngs.h" // for STRING
44#include "tessdatamanager.h" // for TessdataManager
45#include "textord.h" // for Textord
46#include "unichar.h" // for UNICHAR_ID
47#include "wordrec.h" // for Wordrec
48
49class BLOCK_LIST;
50class ETEXT_DESC;
51struct OSResults;
52class PAGE_RES;
53class PAGE_RES_IT;
54struct Pix;
55class ROW;
56class SVMenuNode;
57class TBOX;
58class TO_BLOCK_LIST;
59class WERD;
60class WERD_CHOICE;
61class WERD_RES;
62
63// Top-level class for all tesseract global instance data.
64// This class either holds or points to all data used by an instance
65// of Tesseract, including the memory allocator. When this is
66// complete, Tesseract will be thread-safe. UNTIL THEN, IT IS NOT!
67//
68// NOTE to developers: Do not create cyclic dependencies through this class!
69// The directory dependency tree must remain a tree! The keep this clean,
70// lower-level code (eg in ccutil, the bottom level) must never need to
71// know about the content of a higher-level directory.
72// The following scheme will grant the easiest access to lower-level
73// global members without creating a cyclic dependency:
74//
75// Class Hierarchy (^ = inheritance):
76//
77// CCUtil (ccutil/ccutil.h)
78// ^ Members include: UNICHARSET
79// CUtil (cutil/cutil_class.h)
80// ^ Members include: TBLOB*, TEXTBLOCK*
81// CCStruct (ccstruct/ccstruct.h)
82// ^ Members include: Image
83// Classify (classify/classify.h)
84// ^ Members include: Dict
85// WordRec (wordrec/wordrec.h)
86// ^ Members include: WERD*, DENORM*
87// Tesseract (ccmain/tesseractclass.h)
88// Members include: Pix*
89//
90// Other important classes:
91//
92// TessBaseAPI (api/baseapi.h)
93// Members include: BLOCK_LIST*, PAGE_RES*,
94// Tesseract*, ImageThresholder*
95// Dict (dict/dict.h)
96// Members include: Image* (private)
97//
98// NOTE: that each level contains members that correspond to global
99// data that is defined (and used) at that level, not necessarily where
100// the type is defined so for instance:
101// BOOL_VAR_H(textord_show_blobs, false, "Display unsorted blobs");
102// goes inside the Textord class, not the cc_util class.
103
104namespace tesseract {
105
106class ColumnFinder;
107class DocumentData;
108class EquationDetect;
109class ImageData;
110class LSTMRecognizer;
111class Tesseract;
112
113// A collection of various variables for statistics and debugging.
122 word_count(0),
123 dict_words(0),
126 last_char_was_tilde(false),
128
135 int32_t word_count; // count of word in the document
136 int32_t dict_words; // number of dicitionary words in the document
137 STRING dump_words_str; // accumulator used by dump_words()
138 // Flags used by write_results()
143};
144
145// Struct to hold all the pointers to relevant data for processing a word.
146struct WordData {
148 : word(nullptr), row(nullptr), block(nullptr), prev_word(nullptr) {}
149 explicit WordData(const PAGE_RES_IT& page_res_it)
150 : word(page_res_it.word()),
151 row(page_res_it.row()->row),
152 block(page_res_it.block()->block),
153 prev_word(nullptr) {}
154 WordData(BLOCK* block_in, ROW* row_in, WERD_RES* word_res)
155 : word(word_res), row(row_in), block(block_in), prev_word(nullptr) {}
156
162};
163
164// Definition of a Tesseract WordRecognizer. The WordData provides the context
165// of row/block, in_word holds an initialized, possibly pre-classified word,
166// that the recognizer may or may not consume (but if so it sets
167// *in_word=nullptr) and produces one or more output words in out_words, which
168// may be the consumed in_word, or may be generated independently. This api
169// allows both a conventional tesseract classifier to work, or a line-level
170// classifier that generates multiple words from a merged input.
171using WordRecognizer = void (Tesseract::*)(const WordData&, WERD_RES**,
173
174class Tesseract : public Wordrec {
175 public:
176 Tesseract();
177 ~Tesseract() override;
178
179 // Return appropriate dictionary
180 Dict& getDict() override;
181
182 // Clear as much used memory as possible without resetting the adaptive
183 // classifier or losing any other classifier data.
184 void Clear();
185 // Clear all memory of adaption for this and all subclassifiers.
187 // Clear the document dictionary for this and all subclassifiers.
189
190 // Set the equation detector.
191 void SetEquationDetect(EquationDetect* detector);
192
193 // Simple accessors.
194 const FCOORD& reskew() const {
195 return reskew_;
196 }
197 // Destroy any existing pix and return a pointer to the pointer.
199 pixDestroy(&pix_binary_);
200 return &pix_binary_;
201 }
202 Pix* pix_binary() const {
203 return pix_binary_;
204 }
205 Pix* pix_grey() const {
206 return pix_grey_;
207 }
208 void set_pix_grey(Pix* grey_pix) {
209 pixDestroy(&pix_grey_);
210 pix_grey_ = grey_pix;
211 }
212 Pix* pix_original() const {
213 return pix_original_;
214 }
215 // Takes ownership of the given original_pix.
216 void set_pix_original(Pix* original_pix) {
217 pixDestroy(&pix_original_);
218 pix_original_ = original_pix;
219 // Clone to sublangs as well.
220 for (int i = 0; i < sub_langs_.size(); ++i) {
221 sub_langs_[i]->set_pix_original(original_pix ? pixClone(original_pix)
222 : nullptr);
223 }
224 }
225 // Returns a pointer to a Pix representing the best available resolution image
226 // of the page, with best available bit depth as second priority. Result can
227 // be of any bit depth, but never color-mapped, as that has always been
228 // removed. Note that in grey and color, 0 is black and 255 is
229 // white. If the input was binary, then black is 1 and white is 0.
230 // To tell the difference pixGetDepth() will return 32, 8 or 1.
231 // In any case, the return value is a borrowed Pix, and should not be
232 // deleted or pixDestroyed.
233 Pix* BestPix() const {
234 if (pixGetWidth(pix_original_) == ImageWidth()) {
235 return pix_original_;
236 } else if (pix_grey_ != nullptr) {
237 return pix_grey_;
238 } else {
239 return pix_binary_;
240 }
241 }
242 void set_pix_thresholds(Pix* thresholds) {
243 pixDestroy(&pix_thresholds_);
244 pix_thresholds_ = thresholds;
245 }
246 int source_resolution() const {
247 return source_resolution_;
248 }
249 void set_source_resolution(int ppi) {
250 source_resolution_ = ppi;
251 }
252 int ImageWidth() const {
253 return pixGetWidth(pix_binary_);
254 }
255 int ImageHeight() const {
256 return pixGetHeight(pix_binary_);
257 }
258 Pix* scaled_color() const {
259 return scaled_color_;
260 }
261 int scaled_factor() const {
262 return scaled_factor_;
263 }
264 void SetScaledColor(int factor, Pix* color) {
265 scaled_factor_ = factor;
266 scaled_color_ = color;
267 }
268 const Textord& textord() const {
269 return textord_;
270 }
272 return &textord_;
273 }
274
275 bool right_to_left() const {
276 return right_to_left_;
277 }
278 int num_sub_langs() const {
279 return sub_langs_.size();
280 }
281 Tesseract* get_sub_lang(int index) const {
282 return sub_langs_[index];
283 }
284 // Returns true if any language uses Tesseract (as opposed to LSTM).
285 bool AnyTessLang() const {
287 return true;
288 for (int i = 0; i < sub_langs_.size(); ++i) {
289 if (sub_langs_[i]->tessedit_ocr_engine_mode != OEM_LSTM_ONLY)
290 return true;
291 }
292 return false;
293 }
294 // Returns true if any language uses the LSTM.
295 bool AnyLSTMLang() const {
297 return true;
298 for (int i = 0; i < sub_langs_.size(); ++i) {
299 if (sub_langs_[i]->tessedit_ocr_engine_mode != OEM_TESSERACT_ONLY) {
300 return true;
301 }
302 }
303 return false;
304 }
305
307
308 // Perform steps to prepare underlying binary image/other data structures for
309 // page segmentation. Uses the strategy specified in the global variable
310 // pageseg_devanagari_split_strategy for perform splitting while preparing for
311 // page segmentation.
312 void PrepareForPageseg();
313
314 // Perform steps to prepare underlying binary image/other data structures for
315 // Tesseract OCR. The current segmentation is required by this method.
316 // Uses the strategy specified in the global variable
317 // ocr_devanagari_split_strategy for performing splitting while preparing for
318 // Tesseract ocr.
319 void PrepareForTessOCR(BLOCK_LIST* block_list, Tesseract* osd_tess,
320 OSResults* osr);
321
322 int SegmentPage(const STRING* input_file, BLOCK_LIST* blocks,
323 Tesseract* osd_tess, OSResults* osr);
324 void SetupWordScripts(BLOCK_LIST* blocks);
325 int AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST* blocks,
326 TO_BLOCK_LIST* to_blocks, BLOBNBOX_LIST* diacritic_blobs,
327 Tesseract* osd_tess, OSResults* osr);
329 PageSegMode pageseg_mode, BLOCK_LIST* blocks, Tesseract* osd_tess,
330 OSResults* osr, TO_BLOCK_LIST* to_blocks, Pix** photo_mask_pix,
331 Pix** music_mask_pix);
332 // par_control.cpp
334
336 // Generates training data for training a line recognizer, eg LSTM.
337 // Breaks the page into lines, according to the boxes, and writes them to a
338 // serialized DocumentData based on output_basename.
339 // Return true if successful, false if an error occurred.
340 bool TrainLineRecognizer(const STRING& input_imagename,
341 const STRING& output_basename,
342 BLOCK_LIST* block_list);
343 // Generates training data for training a line recognizer, eg LSTM.
344 // Breaks the boxes into lines, normalizes them, converts to ImageData and
345 // appends them to the given training_data.
346 void TrainFromBoxes(const GenericVector<TBOX>& boxes,
347 const GenericVector<STRING>& texts,
348 BLOCK_LIST* block_list, DocumentData* training_data);
349
350 // Returns an Imagedata containing the image of the given textline,
351 // and ground truth boxes/truth text if available in the input.
352 // The image is not normalized in any way.
353 ImageData* GetLineData(const TBOX& line_box, const GenericVector<TBOX>& boxes,
354 const GenericVector<STRING>& texts, int start_box,
355 int end_box, const BLOCK& block);
356 // Helper gets the image of a rectangle, using the block.re_rotation() if
357 // needed to get to the image, and rotating the result back to horizontal
358 // layout. (CJK characters will be on their left sides) The vertical text flag
359 // is set in the returned ImageData if the text was originally vertical, which
360 // can be used to invoke a different CJK recognition engine. The revised_box
361 // is also returned to enable calculation of output bounding boxes.
362 ImageData* GetRectImage(const TBOX& box, const BLOCK& block, int padding,
363 TBOX* revised_box) const;
364 // Recognizes a word or group of words, converting to WERD_RES in *words.
365 // Analogous to classify_word_pass1, but can handle a group of words as well.
366 void LSTMRecognizeWord(const BLOCK& block, ROW* row, WERD_RES* word,
368 // Apply segmentation search to the given set of words, within the constraints
369 // of the existing ratings matrix. If there is already a best_choice on a word
370 // leaves it untouched and just sets the done/accepted etc flags.
372
374 bool ProcessTargetWord(const TBOX& word_box, const TBOX& target_word_box,
375 const char* word_config, int pass);
376 // Sets up the words ready for whichever engine is to be run
377 void SetupAllWordsPassN(int pass_n, const TBOX* target_word_box,
378 const char* word_config, PAGE_RES* page_res,
380 // Sets up the single word ready for whichever engine is to be run.
381 void SetupWordPassN(int pass_n, WordData* word);
382 // Runs word recognition on all the words.
383 bool RecogAllWordsPassN(int pass_n, ETEXT_DESC* monitor, PAGE_RES_IT* pr_it,
385 bool recog_all_words(PAGE_RES* page_res, ETEXT_DESC* monitor,
386 const TBOX* target_word_box, const char* word_config,
387 int dopasses);
388 void rejection_passes(PAGE_RES* page_res, ETEXT_DESC* monitor,
389 const TBOX* target_word_box, const char* word_config);
390 void bigram_correction_pass(PAGE_RES* page_res);
391 void blamer_pass(PAGE_RES* page_res);
392 // Sets script positions and detects smallcaps on all output words.
393 void script_pos_pass(PAGE_RES* page_res);
394 // Helper to recognize the word using the given (language-specific) tesseract.
395 // Returns positive if this recognizer found more new best words than the
396 // number kept from best_words.
397 int RetryWithLanguage(const WordData& word_data, WordRecognizer recognizer,
398 bool debug, WERD_RES** in_word,
399 PointerVector<WERD_RES>* best_words);
400 // Moves good-looking "noise"/diacritics from the reject list to the main
401 // blob list on the current word. Returns true if anything was done, and
402 // sets make_next_word_fuzzy if blob(s) were added to the end of the word.
403 bool ReassignDiacritics(int pass, PAGE_RES_IT* pr_it,
404 bool* make_next_word_fuzzy);
405 // Attempts to put noise/diacritic outlines into the blobs that they overlap.
406 // Input: a set of noisy outlines that probably belong to the real_word.
407 // Output: outlines that overlapped blobs are set to nullptr and put back into
408 // the word, either in the blobs or in the reject list.
410 const GenericVector<C_OUTLINE*>& outlines, int pass, WERD* real_word,
411 PAGE_RES_IT* pr_it, GenericVector<bool>* word_wanted,
412 GenericVector<bool>* overlapped_any_blob,
413 GenericVector<C_BLOB*>* target_blobs);
414 // Attempts to assign non-overlapping outlines to their nearest blobs or
415 // make new blobs out of them.
417 int pass, WERD* real_word, PAGE_RES_IT* pr_it,
418 GenericVector<bool>* word_wanted,
419 GenericVector<C_BLOB*>* target_blobs);
420 // Starting with ok_outlines set to indicate which outlines overlap the blob,
421 // chooses the optimal set (approximately) and returns true if any outlines
422 // are desired, in which case ok_outlines indicates which ones.
423 bool SelectGoodDiacriticOutlines(int pass, float certainty_threshold,
424 PAGE_RES_IT* pr_it, C_BLOB* blob,
425 const GenericVector<C_OUTLINE*>& outlines,
426 int num_outlines,
427 GenericVector<bool>* ok_outlines);
428 // Classifies the given blob plus the outlines flagged by ok_outlines, undoes
429 // the inclusion of the outlines, and returns the certainty of the raw choice.
430 float ClassifyBlobPlusOutlines(const GenericVector<bool>& ok_outlines,
431 const GenericVector<C_OUTLINE*>& outlines,
432 int pass_n, PAGE_RES_IT* pr_it, C_BLOB* blob,
433 STRING* best_str);
434 // Classifies the given blob (part of word_data->word->word) as an individual
435 // word, using languages, chopper etc, returning only the certainty of the
436 // best raw choice, and undoing all the work done to fake out the word.
437 float ClassifyBlobAsWord(int pass_n, PAGE_RES_IT* pr_it, C_BLOB* blob,
438 STRING* best_str, float* c2);
439 void classify_word_and_language(int pass_n, PAGE_RES_IT* pr_it,
440 WordData* word_data);
441 void classify_word_pass1(const WordData& word_data, WERD_RES** in_word,
442 PointerVector<WERD_RES>* out_words);
443 void recog_pseudo_word(PAGE_RES* page_res, // blocks to check
444 TBOX& selection_box);
445
446 void fix_rep_char(PAGE_RES_IT* page_res_it);
447
449 const char* s,
450 const char* lengths);
451 void match_word_pass_n(int pass_n, WERD_RES* word, ROW* row, BLOCK* block);
452 void classify_word_pass2(const WordData& word_data, WERD_RES** in_word,
453 PointerVector<WERD_RES>* out_words);
454 void ReportXhtFixResult(bool accept_new_word, float new_x_ht, WERD_RES* word,
455 WERD_RES* new_word);
456 bool RunOldFixXht(WERD_RES* word, BLOCK* block, ROW* row);
457 bool TrainedXheightFix(WERD_RES* word, BLOCK* block, ROW* row);
458 // Runs recognition with the test baseline shift and x-height and returns true
459 // if there was an improvement in recognition result.
460 bool TestNewNormalization(int original_misfits, float baseline_shift,
461 float new_x_ht, WERD_RES* word, BLOCK* block,
462 ROW* row);
463 bool recog_interactive(PAGE_RES_IT* pr_it);
464
465 // Set fonts of this word.
466 void set_word_fonts(WERD_RES* word);
467 void font_recognition_pass(PAGE_RES* page_res);
468 void dictionary_correction_pass(PAGE_RES* page_res);
469 bool check_debug_pt(WERD_RES* word, int location);
470
472 bool SubAndSuperscriptFix(WERD_RES* word_res);
474 const WERD_RES* word, int* num_rebuilt_leading, ScriptPos* leading_pos,
475 float* leading_certainty, int* num_rebuilt_trailing,
476 ScriptPos* trailing_pos, float* trailing_certainty, float* avg_certainty,
477 float* unlikely_threshold);
478 WERD_RES* TrySuperscriptSplits(int num_chopped_leading,
479 float leading_certainty, ScriptPos leading_pos,
480 int num_chopped_trailing,
481 float trailing_certainty,
482 ScriptPos trailing_pos, WERD_RES* word,
483 bool* is_good, int* retry_leading,
484 int* retry_trailing);
485 bool BelievableSuperscript(bool debug, const WERD_RES& word,
486 float certainty_threshold, int* left_ok,
487 int* right_ok) const;
488
490
491 void output_pass(PAGE_RES_IT& page_res_it, const TBOX* target_word_box);
492 void write_results(PAGE_RES_IT& page_res_it, // full info
493 char newline_type, // type of newline
494 bool force_eol // override tilde crunch?
495 );
496 void set_unlv_suspects(WERD_RES* word);
497 UNICHAR_ID get_rep_char(WERD_RES* word); // what char is repeated?
498 bool acceptable_number_string(const char* s, const char* lengths);
499 int16_t count_alphanums(const WERD_CHOICE& word);
500 int16_t count_alphas(const WERD_CHOICE& word);
501
502 void read_config_file(const char* filename, SetParamConstraint constraint);
503 // Initialize for potentially a set of languages defined by the language
504 // string and recursively any additional languages required by any language
505 // traineddata file (via tessedit_load_sublangs in its config) that is loaded.
506 // See init_tesseract_internal for args.
507 int init_tesseract(const char* arg0, const char* textbase,
508 const char* language, OcrEngineMode oem, char** configs,
509 int configs_size, const GenericVector<STRING>* vars_vec,
510 const GenericVector<STRING>* vars_values,
511 bool set_only_init_params, TessdataManager* mgr);
512 int init_tesseract(const char* datapath, const char* language,
513 OcrEngineMode oem) {
514 TessdataManager mgr;
515 return init_tesseract(datapath, nullptr, language, oem, nullptr, 0, nullptr,
516 nullptr, false, &mgr);
517 }
518 // Common initialization for a single language.
519 // arg0 is the datapath for the tessdata directory, which could be the
520 // path of the tessdata directory with no trailing /, or (if tessdata
521 // lives in the same directory as the executable, the path of the executable,
522 // hence the name arg0.
523 // textbase is an optional output file basename (used only for training)
524 // language is the language code to load.
525 // oem controls which engine(s) will operate on the image
526 // configs (argv) is an array of config filenames to load variables from.
527 // May be nullptr.
528 // configs_size (argc) is the number of elements in configs.
529 // vars_vec is an optional vector of variables to set.
530 // vars_values is an optional corresponding vector of values for the variables
531 // in vars_vec.
532 // If set_only_init_params is true, then only the initialization variables
533 // will be set.
534 int init_tesseract_internal(const char* arg0, const char* textbase,
535 const char* language, OcrEngineMode oem,
536 char** configs, int configs_size,
537 const GenericVector<STRING>* vars_vec,
538 const GenericVector<STRING>* vars_values,
539 bool set_only_init_params, TessdataManager* mgr);
540
541 // Set the universal_id member of each font to be unique among all
542 // instances of the same font loaded.
544
545 int init_tesseract_lm(const char* arg0, const char* textbase,
546 const char* language, TessdataManager* mgr);
547
548 void recognize_page(STRING& image_name);
549 void end_tesseract();
550
551 bool init_tesseract_lang_data(const char* arg0, const char* textbase,
552 const char* language, OcrEngineMode oem,
553 char** configs, int configs_size,
554 const GenericVector<STRING>* vars_vec,
555 const GenericVector<STRING>* vars_values,
556 bool set_only_init_params,
557 TessdataManager* mgr);
558
559 void ParseLanguageString(const char* lang_str, GenericVector<STRING>* to_load,
560 GenericVector<STRING>* not_to_load);
561
564#ifndef GRAPHICS_DISABLED
565 void pgeditor_main(int width, int height, PAGE_RES* page_res);
566#endif // GRAPHICS_DISABLED
567 void process_image_event( // action in image win
568 const SVEvent& event);
569 bool process_cmd_win_event( // UI command semantics
570 int32_t cmd_event, // which menu item?
571 char* new_value // any prompt data
572 );
573 void debug_word(PAGE_RES* page_res, const TBOX& selection_box);
574 void do_re_display(
575 bool (tesseract::Tesseract::*word_painter)(PAGE_RES_IT* pr_it));
576 bool word_display(PAGE_RES_IT* pr_it);
577 bool word_bln_display(PAGE_RES_IT* pr_it);
579 bool word_set_display(PAGE_RES_IT* pr_it);
580 // #ifndef GRAPHICS_DISABLED
581 bool word_dumper(PAGE_RES_IT* pr_it);
582 // #endif // GRAPHICS_DISABLED
583 void blob_feature_display(PAGE_RES* page_res, const TBOX& selection_box);
585 // make rej map for word
586 void make_reject_map(WERD_RES* word, ROW* row, int16_t pass);
587 bool one_ell_conflict(WERD_RES* word_res, bool update_map);
588 int16_t first_alphanum_index(const char* word, const char* word_lengths);
589 int16_t first_alphanum_offset(const char* word, const char* word_lengths);
590 int16_t alpha_count(const char* word, const char* word_lengths);
591 bool word_contains_non_1_digit(const char* word, const char* word_lengths);
592 void dont_allow_1Il(WERD_RES* word);
593 int16_t count_alphanums( // how many alphanums
594 WERD_RES* word);
595 void flip_0O(WERD_RES* word);
596 bool non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id);
597 bool non_O_upper(const UNICHARSET& ch_set, UNICHAR_ID unichar_id);
598 bool repeated_nonalphanum_wd(WERD_RES* word, ROW* row);
599 void nn_match_word( // Match a word
600 WERD_RES* word, ROW* row);
601 void nn_recover_rejects(WERD_RES* word, ROW* row);
602 void set_done( // set done flag
603 WERD_RES* word, int16_t pass);
604 int16_t safe_dict_word(const WERD_RES* werd_res); // is best_choice in dict?
605 void flip_hyphens(WERD_RES* word);
606 void reject_I_1_L(WERD_RES* word);
607 void reject_edge_blobs(WERD_RES* word);
610 bool word_adaptable( // should we adapt?
611 WERD_RES* word, uint16_t mode);
612
614 void recog_word_recursive(WERD_RES* word);
615 void recog_word(WERD_RES* word);
616 void split_and_recog_word(WERD_RES* word);
617 void split_word(WERD_RES* word, int split_pt, WERD_RES** right_piece,
618 BlamerBundle** orig_blamer_bundle) const;
619 void join_words(WERD_RES* word, WERD_RES* word2, BlamerBundle* orig_bb) const;
621 bool digit_or_numeric_punct(WERD_RES* word, int char_position);
622 int16_t eval_word_spacing(WERD_RES_LIST& word_res_list);
623 void match_current_words(WERD_RES_LIST& words, ROW* row, BLOCK* block);
624 int16_t fp_eval_word_spacing(WERD_RES_LIST& word_res_list);
625 void fix_noisy_space_list(WERD_RES_LIST& best_perm, ROW* row, BLOCK* block);
626 void fix_fuzzy_space_list(WERD_RES_LIST& best_perm, ROW* row, BLOCK* block);
627 void fix_sp_fp_word(WERD_RES_IT& word_res_it, ROW* row, BLOCK* block);
628 void fix_fuzzy_spaces( // find fuzzy words
629 ETEXT_DESC* monitor, // progress monitor
630 int32_t word_count, // count of words in doc
631 PAGE_RES* page_res);
632 void dump_words(WERD_RES_LIST& perm, int16_t score, int16_t mode,
633 bool improved);
635 int16_t worst_noise_blob(WERD_RES* word_res, float* worst_noise_score);
636 float blob_noise_score(TBLOB* blob);
637 void break_noisiest_blob_word(WERD_RES_LIST& words);
639#ifndef DISABLED_LEGACY_ENGINE
640 GARBAGE_LEVEL garbage_word(WERD_RES* word, bool ok_dict_word);
641 bool potential_word_crunch(WERD_RES* word, GARBAGE_LEVEL garbage_level,
642 bool ok_dict_word);
643#endif
644 void tilde_crunch(PAGE_RES_IT& page_res_it);
645 void unrej_good_quality_words( // unreject potential
646 PAGE_RES_IT& page_res_it);
647 void doc_and_block_rejection( // reject big chunks
648 PAGE_RES_IT& page_res_it, bool good_quality_doc);
649 void quality_based_rejection(PAGE_RES_IT& page_res_it, bool good_quality_doc);
650 void convert_bad_unlv_chs(WERD_RES* word_res);
651 void tilde_delete(PAGE_RES_IT& page_res_it);
652 int16_t word_blob_quality(WERD_RES* word, ROW* row);
653 void word_char_quality(WERD_RES* word, ROW* row, int16_t* match_count,
654 int16_t* accepted_match_count);
655 void unrej_good_chs(WERD_RES* word, ROW* row);
656 int16_t count_outline_errs(char c, int16_t outline_count);
657 int16_t word_outline_errs(WERD_RES* word);
658#ifndef DISABLED_LEGACY_ENGINE
659 bool terrible_word_crunch(WERD_RES* word, GARBAGE_LEVEL garbage_level);
660#endif
661 CRUNCH_MODE word_deletable(WERD_RES* word, int16_t& delete_mode);
662 int16_t failure_count(WERD_RES* word);
663 bool noise_outlines(TWERD* word);
666 PAGE_RES* page_res, // blocks to check
667 // function to call
668 TBOX& selection_box,
669 bool (tesseract::Tesseract::*word_processor)(PAGE_RES_IT* pr_it));
671 void tess_add_doc_word( // test acceptability
672 WERD_CHOICE* word_choice // after context
673 );
674 void tess_segment_pass_n(int pass_n, WERD_RES* word);
675 bool tess_acceptable_word(WERD_RES* word);
676
678 // Applies the box file based on the image name fname, and resegments
679 // the words in the block_list (page), with:
680 // blob-mode: one blob per line in the box file, words as input.
681 // word/line-mode: one blob per space-delimited unit after the #, and one word
682 // per line in the box file. (See comment above for box file format.)
683 // If find_segmentation is true, (word/line mode) then the classifier is used
684 // to re-segment words/lines to match the space-delimited truth string for
685 // each box. In this case, the input box may be for a word or even a whole
686 // text line, and the output words will contain multiple blobs corresponding
687 // to the space-delimited input string.
688 // With find_segmentation false, no classifier is needed, but the chopper
689 // can still be used to correctly segment touching characters with the help
690 // of the input boxes.
691 // In the returned PAGE_RES, the WERD_RES are setup as they would be returned
692 // from normal classification, ie. with a word, chopped_word, rebuild_word,
693 // seam_array, denorm, box_word, and best_state, but NO best_choice or
694 // raw_choice, as they would require a UNICHARSET, which we aim to avoid.
695 // Instead, the correct_text member of WERD_RES is set, and this may be later
696 // converted to a best_choice using CorrectClassifyWords. CorrectClassifyWords
697 // is not required before calling ApplyBoxTraining.
698 PAGE_RES* ApplyBoxes(const STRING& fname, bool find_segmentation,
699 BLOCK_LIST* block_list);
700
701 // Any row xheight that is significantly different from the median is set
702 // to the median.
703 void PreenXHeights(BLOCK_LIST* block_list);
704
705 // Builds a PAGE_RES from the block_list in the way required for ApplyBoxes:
706 // All fuzzy spaces are removed, and all the words are maximally chopped.
708 BLOCK_LIST* block_list);
709 // Tests the chopper by exhaustively running chop_one_blob.
710 // The word_res will contain filled chopped_word, seam_array, denorm,
711 // box_word and best_state for the maximally chopped word.
712 void MaximallyChopWord(const GenericVector<TBOX>& boxes, BLOCK* block,
713 ROW* row, WERD_RES* word_res);
714 // Gather consecutive blobs that match the given box into the best_state
715 // and corresponding correct_text.
716 // Fights over which box owns which blobs are settled by pre-chopping and
717 // applying the blobs to box or next_box with the least non-overlap.
718 // Returns false if the box was in error, which can only be caused by
719 // failing to find an appropriate blob for a box.
720 // This means that occasionally, blobs may be incorrectly segmented if the
721 // chopper fails to find a suitable chop point.
722 bool ResegmentCharBox(PAGE_RES* page_res, const TBOX* prev_box,
723 const TBOX& box, const TBOX* next_box,
724 const char* correct_text);
725 // Consume all source blobs that strongly overlap the given box,
726 // putting them into a new word, with the correct_text label.
727 // Fights over which box owns which blobs are settled by
728 // applying the blobs to box or next_box with the least non-overlap.
729 // Returns false if the box was in error, which can only be caused by
730 // failing to find an overlapping blob for a box.
731 bool ResegmentWordBox(BLOCK_LIST* block_list, const TBOX& box,
732 const TBOX* next_box, const char* correct_text);
733 // Resegments the words by running the classifier in an attempt to find the
734 // correct segmentation that produces the required string.
735 void ReSegmentByClassification(PAGE_RES* page_res);
736 // Converts the space-delimited string of utf8 text to a vector of UNICHAR_ID.
737 // Returns false if an invalid UNICHAR_ID is encountered.
738 bool ConvertStringToUnichars(const char* utf8,
739 GenericVector<UNICHAR_ID>* class_ids);
740 // Resegments the word to achieve the target_text from the classifier.
741 // Returns false if the re-segmentation fails.
742 // Uses brute-force combination of up to kMaxGroupSize adjacent blobs, and
743 // applies a full search on the classifier results to find the best classified
744 // segmentation. As a compromise to obtain better recall, 1-1 ambigiguity
745 // substitutions ARE used.
746 bool FindSegmentation(const GenericVector<UNICHAR_ID>& target_text,
747 WERD_RES* word_res);
748 // Recursive helper to find a match to the target_text (from text_index
749 // position) in the choices (from choices_pos position).
750 // Choices is an array of GenericVectors, of length choices_length, with each
751 // element representing a starting position in the word, and the
752 // GenericVector holding classification results for a sequence of consecutive
753 // blobs, with index 0 being a single blob, index 1 being 2 blobs etc.
755 int choices_pos, int choices_length,
756 const GenericVector<UNICHAR_ID>& target_text,
757 int text_index, float rating,
758 GenericVector<int>* segmentation, float* best_rating,
759 GenericVector<int>* best_segmentation);
760 // Counts up the labelled words and the blobs within.
761 // Deletes all unused or emptied words, counting the unused ones.
762 // Resets W_BOL and W_EOL flags correctly.
763 // Builds the rebuild_word and rebuilds the box_word.
764 void TidyUp(PAGE_RES* page_res);
765 // Logs a bad box by line in the box file and box coords.
766 void ReportFailedBox(int boxfile_lineno, TBOX box, const char* box_ch,
767 const char* err_msg);
768 // Creates a fake best_choice entry in each WERD_RES with the correct text.
769 void CorrectClassifyWords(PAGE_RES* page_res);
770 // Call LearnWord to extract features for labelled blobs within each word.
771 // Features are stored in an internal buffer.
772 void ApplyBoxTraining(const STRING& fontname, PAGE_RES* page_res);
773
775 // Returns the number of misfit blob tops in this word.
776 int CountMisfitTops(WERD_RES* word_res);
777 // Returns a new x-height in pixels (original image coords) that is
778 // maximally compatible with the result in word_res.
779 // Returns 0.0f if no x-height is found that is better than the current
780 // estimate.
781 float ComputeCompatibleXheight(WERD_RES* word_res, float* baseline_shift);
783 // TODO(ocr-team): Find and remove obsolete parameters.
785 "Take segmentation and labeling from box file");
787 "Conversion of word/line box file to char box file");
789 "Generate training data from boxed chars");
791 "Generate more boxes from boxed chars");
793 "Break input into lines and remap boxes if present");
795 "Dump intermediate images made during page segmentation");
797 "Try inverting the image in `LSTMRecognizeWord`");
799 "Page seg mode: 0=osd only, 1=auto+osd, 2=auto, 3=col, 4=block,"
800 " 5=line, 6=word, 7=char"
801 " (Values from PageSegMode enum in publictypes.h)");
803 "Which OCR engine(s) to run (Tesseract, LSTM, both). Defaults"
804 " to loading and running the most accurate available.");
806 "Blacklist of chars not to recognize");
807 STRING_VAR_H(tessedit_char_whitelist, "", "Whitelist of chars to recognize");
809 "List of chars to override tessedit_char_blacklist");
811 "Perform training for ambiguities");
814 "Whether to use the top-line splitting process for Devanagari "
815 "documents while performing page-segmentation.");
818 "Whether to use the top-line splitting process for Devanagari "
819 "documents while performing ocr.");
821 "Write all parameters to the given file.");
823 "Generate and print debug information for adaption");
824 INT_VAR_H(bidi_debug, 0, "Debug level for BiDi");
825 INT_VAR_H(applybox_debug, 1, "Debug level");
826 INT_VAR_H(applybox_page, 0, "Page number to apply boxes from");
828 "Exposure value follows this pattern in the image"
829 " filename. The name of the image files are expected"
830 " to be in the form [lang].[fontname].exp[num].tif");
832 "Learn both character fragments (as is done in the"
833 " special low exposure mode) as well as unfragmented"
834 " characters.");
836 "Each bounding box is assumed to contain ngrams. Only"
837 " learn the ngrams whose outlines overlap horizontally.");
838 BOOL_VAR_H(tessedit_display_outwords, false, "Draw output words");
839 BOOL_VAR_H(tessedit_dump_choices, false, "Dump char choices");
840 BOOL_VAR_H(tessedit_timing_debug, false, "Print timing stats");
841 BOOL_VAR_H(tessedit_fix_fuzzy_spaces, true, "Try to improve fuzzy spaces");
843 "Don't bother with word plausibility");
844 BOOL_VAR_H(tessedit_fix_hyphens, true, "Crunch double hyphens?");
846 "Add words to the document dictionary");
847 BOOL_VAR_H(tessedit_debug_fonts, false, "Output font info per char");
848 BOOL_VAR_H(tessedit_debug_block_rejection, false, "Block and Row stats");
850 "Enable correction based on the word bigram dictionary.");
852 "Enable single word correction based on the dictionary.");
854 "Amount of debug output for bigram "
855 "correction.");
857 "Remove and conditionally reassign small outlines when they"
858 " confuse layout analysis, determining diacritics vs noise");
859 INT_VAR_H(debug_noise_removal, 0, "Debug reassignment of small outlines");
860 // Worst (min) certainty, for which a diacritic is allowed to make the base
861 // character worse and still be included.
862 double_VAR_H(noise_cert_basechar, -8.0, "Hingepoint for base char certainty");
863 // Worst (min) certainty, for which a non-overlapping diacritic is allowed to
864 // make the base character worse and still be included.
865 double_VAR_H(noise_cert_disjoint, -2.5, "Hingepoint for disjoint certainty");
866 // Worst (min) certainty, for which a diacritic is allowed to make a new
867 // stand-alone blob.
868 double_VAR_H(noise_cert_punc, -2.5, "Threshold for new punc char certainty");
869 // Factor of certainty margin for adding diacritics to not count as worse.
871 "Scaling on certainty diff from Hingepoint");
872 INT_VAR_H(noise_maxperblob, 8, "Max diacritics to apply to a blob");
873 INT_VAR_H(noise_maxperword, 16, "Max diacritics to apply to a word");
874 INT_VAR_H(debug_x_ht_level, 0, "Reestimate debug");
875 STRING_VAR_H(chs_leading_punct, "('`\"", "Leading punctuation");
876 STRING_VAR_H(chs_trailing_punct1, ").,;:?!", "1st Trailing punctuation");
877 STRING_VAR_H(chs_trailing_punct2, ")'`\"", "2nd Trailing punctuation");
878 double_VAR_H(quality_rej_pc, 0.08, "good_quality_doc lte rejection limit");
879 double_VAR_H(quality_blob_pc, 0.0, "good_quality_doc gte good blobs limit");
881 "good_quality_doc lte outline error limit");
882 double_VAR_H(quality_char_pc, 0.95, "good_quality_doc gte good char limit");
883 INT_VAR_H(quality_min_initial_alphas_reqd, 2, "alphas in a good word");
885 "Adaptation decision algorithm for tess");
887 "Do minimal rejection on pass 1 output");
888 BOOL_VAR_H(tessedit_test_adaption, false, "Test adaption criteria");
889 BOOL_VAR_H(test_pt, false, "Test for point");
890 double_VAR_H(test_pt_x, 99999.99, "xcoord");
891 double_VAR_H(test_pt_y, 99999.99, "ycoord");
892 INT_VAR_H(multilang_debug_level, 0, "Print multilang debug info.");
893 INT_VAR_H(paragraph_debug_level, 0, "Print paragraph debug info.");
895 "Run paragraph detection on the post-text-recognition "
896 "(more accurate)");
897 BOOL_VAR_H(lstm_use_matrix, 1, "Use ratings matrix/beam searct with lstm");
898 STRING_VAR_H(outlines_odd, "%| ", "Non standard number of outlines");
899 STRING_VAR_H(outlines_2, "ij!?%\":;", "Non standard number of outlines");
901 "Reduce rejection on good docs");
902 BOOL_VAR_H(tessedit_use_reject_spaces, true, "Reject spaces?");
904 "%rej allowed before rej whole doc");
906 "%rej allowed before rej whole block");
908 "%rej allowed before rej whole row");
910 "Number of row rejects in whole word rejects"
911 "which prevents whole row rejection");
913 "Only rej partially rejected words in block rejection");
915 "Only rej partially rejected words in row rejection");
917 "Use word segmentation quality metric");
919 "Use word segmentation quality metric");
921 "Only preserve wds longer than this");
923 "Apply row rejection to good docs");
925 "rej good doc wd if more than this fraction rejected");
926 BOOL_VAR_H(tessedit_reject_bad_qual_wds, true, "Reject all bad quality wds");
929 "Output data to debug file");
930 BOOL_VAR_H(bland_unrej, false, "unrej potential with no checks");
931 double_VAR_H(quality_rowrej_pc, 1.1, "good_quality_doc gte good char limit");
932 BOOL_VAR_H(unlv_tilde_crunching, false, "Mark v.bad words for tilde crunch");
933 BOOL_VAR_H(hocr_font_info, false, "Add font info to hocr output");
935 "Add coordinates for each character to hocr output");
936 BOOL_VAR_H(crunch_early_merge_tess_fails, true, "Before word crunch?");
937 BOOL_VAR_H(crunch_early_convert_bad_unlv_chs, false, "Take out ~^ early?");
938 double_VAR_H(crunch_terrible_rating, 80.0, "crunch rating lt this");
940 double_VAR_H(crunch_poor_garbage_cert, -9.0, "crunch garbage cert lt this");
941 double_VAR_H(crunch_poor_garbage_rate, 60, "crunch garbage rating lt this");
942 double_VAR_H(crunch_pot_poor_rate, 40, "POTENTIAL crunch rating lt this");
943 double_VAR_H(crunch_pot_poor_cert, -8.0, "POTENTIAL crunch cert lt this");
944 double_VAR_H(crunch_del_rating, 60, "POTENTIAL crunch rating lt this");
945 double_VAR_H(crunch_del_cert, -10.0, "POTENTIAL crunch cert lt this");
946 double_VAR_H(crunch_del_min_ht, 0.7, "Del if word ht lt xht x this");
947 double_VAR_H(crunch_del_max_ht, 3.0, "Del if word ht gt xht x this");
948 double_VAR_H(crunch_del_min_width, 3.0, "Del if word width lt xht x this");
949 double_VAR_H(crunch_del_high_word, 1.5, "Del if word gt xht x this above bl");
950 double_VAR_H(crunch_del_low_word, 0.5, "Del if word gt xht x this below bl");
951 double_VAR_H(crunch_small_outlines_size, 0.6, "Small if lt xht x this");
952 INT_VAR_H(crunch_rating_max, 10, "For adj length in rating per ch");
953 INT_VAR_H(crunch_pot_indicators, 1, "How many potential indicators needed");
954 BOOL_VAR_H(crunch_leave_ok_strings, true, "Don't touch sensible strings");
955 BOOL_VAR_H(crunch_accept_ok, true, "Use acceptability in okstring");
957 "Don't pot crunch sensible strings");
958 BOOL_VAR_H(crunch_include_numerals, false, "Fiddle alpha figures");
960 "Don't crunch words with long lower case strings");
962 "Don't crunch words with long lower case strings");
963 INT_VAR_H(crunch_long_repetitions, 3, "Crunch words with long repetitions");
964 INT_VAR_H(crunch_debug, 0, "As it says");
965 INT_VAR_H(fixsp_non_noise_limit, 1, "How many non-noise blbs either side?");
966 double_VAR_H(fixsp_small_outlines_size, 0.28, "Small if lt xht x this");
967 BOOL_VAR_H(tessedit_prefer_joined_punct, false, "Reward punctuation joins");
968 INT_VAR_H(fixsp_done_mode, 1, "What constitues done for spacing");
969 INT_VAR_H(debug_fix_space_level, 0, "Contextual fixspace debug");
970 STRING_VAR_H(numeric_punctuation, ".,", "Punct. chs expected WITHIN numbers");
972 "Max allowed deviation of blob top outside of font data");
973 INT_VAR_H(x_ht_min_change, 8, "Min change in xht before actually trying it");
974 INT_VAR_H(superscript_debug, 0, "Debug level for sub & superscript fixer");
976 "How many times worse "
977 "certainty does a superscript position glyph need to be for us "
978 "to try classifying it as a char with a different baseline?");
980 "What reduction in "
981 "badness do we think sufficient to choose a superscript over "
982 "what we'd thought. For example, a value of 0.6 means we want "
983 "to reduce badness of certainty by 40%");
985 "A superscript scaled down more than this is unbelievably "
986 "small. For example, 0.3 means we expect the font size to "
987 "be no smaller than 30% of the text line font size.");
989 "Maximum top of a character measured as a multiple of x-height "
990 "above the baseline for us to reconsider whether it's a "
991 "subscript.");
993 "Minimum bottom of a character measured as a multiple of "
994 "x-height above the baseline for us to reconsider whether it's "
995 "a superscript.");
997 "Write block separators in output");
998 BOOL_VAR_H(tessedit_write_rep_codes, false, "Write repetition char code");
999 BOOL_VAR_H(tessedit_write_unlv, false, "Write .unlv output file");
1000 BOOL_VAR_H(tessedit_create_txt, false, "Write .txt output file");
1001 BOOL_VAR_H(tessedit_create_hocr, false, "Write .html hOCR output file");
1002 BOOL_VAR_H(tessedit_create_alto, false, "Write .xml ALTO output file");
1004 "Write .box file for LSTM training");
1005 BOOL_VAR_H(tessedit_create_tsv, false, "Write .tsv output file");
1007 "Write WordStr format .box output file");
1008 BOOL_VAR_H(tessedit_create_pdf, false, "Write .pdf output file");
1009 BOOL_VAR_H(textonly_pdf, false,
1010 "Create PDF with only one invisible text layer");
1011 INT_VAR_H(jpg_quality, 85, "Set JPEG quality level");
1012 INT_VAR_H(user_defined_dpi, 0, "Specify DPI for input image");
1014 "Specify minimum characters to try during OSD");
1015 STRING_VAR_H(unrecognised_char, "|", "Output char for unidentified blobs");
1016 INT_VAR_H(suspect_level, 99, "Suspect marker level");
1017 INT_VAR_H(suspect_short_words, 2, "Don't Suspect dict wds longer than this");
1018 BOOL_VAR_H(suspect_constrain_1Il, false, "UNLV keep 1Il chars rejected");
1019 double_VAR_H(suspect_rating_per_ch, 999.9, "Don't touch bad rating limit");
1020 double_VAR_H(suspect_accept_rating, -999.9, "Accept good rating limit");
1021 BOOL_VAR_H(tessedit_minimal_rejection, false, "Only reject tess failures");
1022 BOOL_VAR_H(tessedit_zero_rejection, false, "Don't reject ANYTHING");
1024 "Make output have exactly one word per WERD");
1026 "Don't reject ANYTHING AT ALL");
1027 INT_VAR_H(tessedit_reject_mode, 0, "Rejection algorithm");
1028 BOOL_VAR_H(tessedit_rejection_debug, false, "Adaption debug");
1029 BOOL_VAR_H(tessedit_flip_0O, true, "Contextual 0O O0 flips");
1030 double_VAR_H(tessedit_lower_flip_hyphen, 1.5, "Aspect ratio dot/hyphen test");
1031 double_VAR_H(tessedit_upper_flip_hyphen, 1.8, "Aspect ratio dot/hyphen test");
1032 BOOL_VAR_H(rej_trust_doc_dawg, false, "Use DOC dawg in 11l conf. detector");
1033 BOOL_VAR_H(rej_1Il_use_dict_word, false, "Use dictword test");
1034 BOOL_VAR_H(rej_1Il_trust_permuter_type, true, "Don't double check");
1035 BOOL_VAR_H(rej_use_tess_accepted, true, "Individual rejection control");
1036 BOOL_VAR_H(rej_use_tess_blanks, true, "Individual rejection control");
1037 BOOL_VAR_H(rej_use_good_perm, true, "Individual rejection control");
1038 BOOL_VAR_H(rej_use_sensible_wd, false, "Extend permuter check");
1039 BOOL_VAR_H(rej_alphas_in_number_perm, false, "Extend permuter check");
1041 INT_VAR_H(tessedit_image_border, 2, "Rej blbs near image edge limit");
1042 STRING_VAR_H(ok_repeated_ch_non_alphanum_wds, "-?*\075", "Allow NN to unrej");
1043 STRING_VAR_H(conflict_set_I_l_1, "Il1[]", "Il1 conflict set");
1044 INT_VAR_H(min_sane_x_ht_pixels, 8, "Reject any x-ht lt or eq than this");
1045 BOOL_VAR_H(tessedit_create_boxfile, false, "Output text with boxes");
1047 "-1 -> All pages, else specific page to process");
1048 BOOL_VAR_H(tessedit_write_images, false, "Capture the image from the IPE");
1049 BOOL_VAR_H(interactive_display_mode, false, "Run interactively?");
1050 STRING_VAR_H(file_type, ".tif", "Filename extension");
1051 BOOL_VAR_H(tessedit_override_permuter, true, "According to dict_word");
1053 "List of languages to load with this one");
1055 "In multilingual mode use params model of the primary language");
1056 // Min acceptable orientation margin (difference in scores between top and 2nd
1057 // choice in OSResults::orientations) to believe the page orientation.
1059 "Min acceptable orientation margin");
1060 BOOL_VAR_H(textord_tabfind_show_vlines, false, "Debug line finding");
1061 BOOL_VAR_H(textord_use_cjk_fp_model, false, "Use CJK fixed pitch model");
1063 "Allow feature extractors to see the original outline");
1065 "Only initialize with the config file. Useful if the instance is "
1066 "not going to be used for OCR but say only for layout analysis.");
1067 BOOL_VAR_H(textord_equation_detect, false, "Turn on equation detector");
1068 BOOL_VAR_H(textord_tabfind_vertical_text, true, "Enable vertical detection");
1070 "Force using vertical text page mode");
1072 "Fraction of textlines deemed vertical to use vertical page "
1073 "mode");
1075 "Fraction of height used as a minimum gap for aligned blobs.");
1076 INT_VAR_H(tessedit_parallelize, 0, "Run in parallel where possible");
1078 "Preserve multiple interword spaces");
1080 "Page separator (default is form feed control character)");
1082 "Allows to include alternative symbols choices in the hOCR "
1083 "output. "
1084 "Valid input values are 0, 1, 2 and 3. 0 is the default value. "
1085 "With 1 the alternative symbol choices per timestep are included. "
1086 "With 2 the alternative symbol choices are accumulated per "
1087 "character. ");
1089 "Detect music staff and remove intersecting components");
1090
1092 FILE* init_recog_training(const STRING& fname);
1093 void recog_training_segmented(const STRING& fname, PAGE_RES* page_res,
1094 volatile ETEXT_DESC* monitor,
1095 FILE* output_file);
1096 void ambigs_classify_and_output(const char* label, PAGE_RES_IT* pr_it,
1097 FILE* output_file);
1098
1099 private:
1100 // The filename of a backup config file. If not null, then we currently
1101 // have a temporary debug config file loaded, and backup_config_file_
1102 // will be loaded, and set to null when debug is complete.
1103 const char* backup_config_file_;
1104 // The filename of a config file to read when processing a debug word.
1105 STRING word_config_;
1106 // Image used for input to layout analysis and tesseract recognition.
1107 // May be modified by the ShiroRekhaSplitter to eliminate the top-line.
1108 Pix* pix_binary_;
1109 // Grey-level input image if the input was not binary, otherwise nullptr.
1110 Pix* pix_grey_;
1111 // Original input image. Color if the input was color.
1112 Pix* pix_original_;
1113 // Thresholds that were used to generate the thresholded image from grey.
1114 Pix* pix_thresholds_;
1115 // Debug images. If non-empty, will be written on destruction.
1116 DebugPixa pixa_debug_;
1117 // Input image resolution after any scaling. The resolution is not well
1118 // transmitted by operations on Pix, so we keep an independent record here.
1119 int source_resolution_;
1120 // The shiro-rekha splitter object which is used to split top-lines in
1121 // Devanagari words to provide a better word and grapheme segmentation.
1122 ShiroRekhaSplitter splitter_;
1123 // Page segmentation/layout
1124 Textord textord_;
1125 // True if the primary language uses right_to_left reading order.
1126 bool right_to_left_;
1127 Pix* scaled_color_;
1128 int scaled_factor_;
1129 FCOORD deskew_;
1130 FCOORD reskew_;
1131 TesseractStats stats_;
1132 // Sub-languages to be tried in addition to this.
1133 GenericVector<Tesseract*> sub_langs_;
1134 // Most recently used Tesseract out of this and sub_langs_. The default
1135 // language for the next word.
1136 Tesseract* most_recently_used_;
1137 // The size of the font table, ie max possible font id + 1.
1138 int font_table_size_;
1139 // Equation detector. Note: this pointer is NOT owned by the class.
1140 EquationDetect* equ_detect_;
1141 // LSTM recognizer, if available.
1142 LSTMRecognizer* lstm_recognizer_;
1143 // Output "page" number (actually line number) using TrainLineRecognizer.
1144 int train_line_page_num_;
1145};
1146
1147} // namespace tesseract
1148
1149#endif // TESSERACT_CCMAIN_TESSERACTCLASS_H_
ACCEPTABLE_WERD_TYPE
Definition: control.h:29
GARBAGE_LEVEL
Definition: docqual.h:30
CRUNCH_MODE
Definition: pageres.h:157
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:297
#define STRING_VAR_H(name, val, comment)
Definition: params.h:299
#define INT_VAR_H(name, val, comment)
Definition: params.h:295
#define double_VAR_H(name, val, comment)
Definition: params.h:301
int UNICHAR_ID
Definition: unichar.h:34
@ OEM_TESSERACT_ONLY
Definition: publictypes.h:269
SetParamConstraint
Definition: params.h:35
@ PSM_SINGLE_BLOCK
Assume a single uniform block of text. (Default.)
Definition: publictypes.h:172
void(Tesseract::*)(const WordData &, WERD_RES **, PointerVector< WERD_RES > *) WordRecognizer
WordData(BLOCK *block_in, ROW *row_in, WERD_RES *word_res)
WordData(const PAGE_RES_IT &page_res_it)
PointerVector< WERD_RES > lang_words
void recog_training_segmented(const STRING &fname, PAGE_RES *page_res, volatile ETEXT_DESC *monitor, FILE *output_file)
int16_t first_alphanum_index(const char *word, const char *word_lengths)
Definition: reject.cpp:470
void LSTMRecognizeWord(const BLOCK &block, ROW *row, WERD_RES *word, PointerVector< WERD_RES > *words)
Definition: linerec.cpp:229
ColumnFinder * SetupPageSegAndDetectOrientation(PageSegMode pageseg_mode, BLOCK_LIST *blocks, Tesseract *osd_tess, OSResults *osr, TO_BLOCK_LIST *to_blocks, Pix **photo_mask_pix, Pix **music_mask_pix)
void tilde_delete(PAGE_RES_IT &page_res_it)
Definition: docqual.cpp:589
void reject_edge_blobs(WERD_RES *word)
Definition: reject.cpp:264
GARBAGE_LEVEL garbage_word(WERD_RES *word, bool ok_dict_word)
Definition: docqual.cpp:679
int16_t first_alphanum_offset(const char *word, const char *word_lengths)
Definition: reject.cpp:483
bool recog_interactive(PAGE_RES_IT *pr_it)
Definition: control.cpp:77
double tessedit_reject_doc_percent
void process_image_event(const SVEvent &event)
Definition: pgedit.cpp:587
bool fixspace_thinks_word_done(WERD_RES *word)
Definition: fixspace.cpp:530
void classify_word_and_language(int pass_n, PAGE_RES_IT *pr_it, WordData *word_data)
Definition: control.cpp:1319
void SetEquationDetect(EquationDetect *detector)
void fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK *block)
Definition: fixspace.cpp:596
bool acceptable_number_string(const char *s, const char *lengths)
Definition: output.cpp:387
Pix * scaled_color() const
bool process_cmd_win_event(int32_t cmd_event, char *new_value)
Definition: pgedit.cpp:415
int init_tesseract(const char *arg0, const char *textbase, const char *language, OcrEngineMode oem, char **configs, int configs_size, const GenericVector< STRING > *vars_vec, const GenericVector< STRING > *vars_values, bool set_only_init_params, TessdataManager *mgr)
Definition: tessedit.cpp:286
bool non_O_upper(const UNICHARSET &ch_set, UNICHAR_ID unichar_id)
Definition: reject.cpp:786
int16_t alpha_count(const char *word, const char *word_lengths)
Definition: reject.cpp:496
void match_word_pass_n(int pass_n, WERD_RES *word, ROW *row, BLOCK *block)
Definition: control.cpp:1630
void dont_allow_1Il(WERD_RES *word)
Definition: reject.cpp:527
void bigram_correction_pass(PAGE_RES *page_res)
Definition: control.cpp:467
bool tessedit_preserve_row_rej_perfect_wds
double superscript_bettered_certainty
double superscript_worse_certainty
ImageData * GetLineData(const TBOX &line_box, const GenericVector< TBOX > &boxes, const GenericVector< STRING > &texts, int start_box, int end_box, const BLOCK &block)
Definition: linerec.cpp:136
int AutoPageSeg(PageSegMode pageseg_mode, BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks, BLOBNBOX_LIST *diacritic_blobs, Tesseract *osd_tess, OSResults *osr)
void GetSubAndSuperscriptCandidates(const WERD_RES *word, int *num_rebuilt_leading, ScriptPos *leading_pos, float *leading_certainty, int *num_rebuilt_trailing, ScriptPos *trailing_pos, float *trailing_certainty, float *avg_certainty, float *unlikely_threshold)
SVMenuNode * build_menu_new()
Definition: pgedit.cpp:298
float ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_shift)
Definition: fixxht.cpp:102
void SetupAllWordsPassN(int pass_n, const TBOX *target_word_box, const char *word_config, PAGE_RES *page_res, GenericVector< WordData > *words)
Definition: control.cpp:154
void fix_rep_char(PAGE_RES_IT *page_res_it)
Definition: control.cpp:1706
int16_t count_alphanums(const WERD_CHOICE &word)
Definition: output.cpp:376
int16_t worst_noise_blob(WERD_RES *word_res, float *worst_noise_score)
Definition: fixspace.cpp:707
void set_unlv_suspects(WERD_RES *word)
Definition: output.cpp:273
int init_tesseract_internal(const char *arg0, const char *textbase, const char *language, OcrEngineMode oem, char **configs, int configs_size, const GenericVector< STRING > *vars_vec, const GenericVector< STRING > *vars_values, bool set_only_init_params, TessdataManager *mgr)
Definition: tessedit.cpp:386
void fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK *block)
Definition: fixspace.cpp:562
bool ConvertStringToUnichars(const char *utf8, GenericVector< UNICHAR_ID > *class_ids)
Definition: applybox.cpp:534
Pix * pix_binary() const
void SetupUniversalFontIds()
Definition: tessedit.cpp:431
void tilde_crunch(PAGE_RES_IT &page_res_it)
Definition: docqual.cpp:417
void set_pix_grey(Pix *grey_pix)
void SetupWordPassN(int pass_n, WordData *word)
Definition: control.cpp:177
int SegmentPage(const STRING *input_file, BLOCK_LIST *blocks, Tesseract *osd_tess, OSResults *osr)
Definition: pagesegmain.cpp:99
double textord_tabfind_vertical_text_ratio
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
Definition: control.cpp:62
bool ResegmentWordBox(BLOCK_LIST *block_list, const TBOX &box, const TBOX *next_box, const char *correct_text)
Definition: applybox.cpp:431
void doc_and_block_rejection(PAGE_RES_IT &page_res_it, bool good_quality_doc)
Definition: docqual.cpp:232
int16_t word_outline_errs(WERD_RES *word)
Definition: docqual.cpp:72
void rejection_passes(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config)
Definition: control.cpp:612
void split_word(WERD_RES *word, int split_pt, WERD_RES **right_piece, BlamerBundle **orig_blamer_bundle) const
Definition: tfacepp.cpp:176
int num_sub_langs() const
void tess_segment_pass_n(int pass_n, WERD_RES *word)
Definition: tessbox.cpp:32
bool SelectGoodDiacriticOutlines(int pass, float certainty_threshold, PAGE_RES_IT *pr_it, C_BLOB *blob, const GenericVector< C_OUTLINE * > &outlines, int num_outlines, GenericVector< bool > *ok_outlines)
Definition: control.cpp:1140
Textord * mutable_textord()
float blob_noise_score(TBLOB *blob)
Definition: fixspace.cpp:787
bool tessedit_enable_bigram_correction
void TidyUp(PAGE_RES *page_res)
Definition: applybox.cpp:708
bool applybox_learn_chars_and_char_frags_mode
void read_config_file(const char *filename, SetParamConstraint constraint)
Definition: tessedit.cpp:48
bool crunch_early_convert_bad_unlv_chs
FILE * init_recog_training(const STRING &fname)
void SetScaledColor(int factor, Pix *color)
ACCEPTABLE_WERD_TYPE acceptable_word_string(const UNICHARSET &char_set, const char *s, const char *lengths)
Definition: control.cpp:1745
Pix * pix_grey() const
void split_and_recog_word(WERD_RES *word)
Definition: tfacepp.cpp:138
void fix_fuzzy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK *block)
Definition: fixspace.cpp:172
Pix * BestPix() const
bool one_ell_conflict(WERD_RES *word_res, bool update_map)
Definition: reject.cpp:293
void dump_words(WERD_RES_LIST &perm, int16_t score, int16_t mode, bool improved)
Definition: fixspace.cpp:476
bool ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const TBOX &box, const TBOX *next_box, const char *correct_text)
Definition: applybox.cpp:329
void output_pass(PAGE_RES_IT &page_res_it, const TBOX *target_word_box)
Definition: output.cpp:36
void SearchForText(const GenericVector< BLOB_CHOICE_LIST * > *choices, int choices_pos, int choices_length, const GenericVector< UNICHAR_ID > &target_text, int text_index, float rating, GenericVector< int > *segmentation, float *best_rating, GenericVector< int > *best_segmentation)
Definition: applybox.cpp:631
void ReSegmentByClassification(PAGE_RES *page_res)
Definition: applybox.cpp:506
Dict & getDict() override
void ApplyBoxTraining(const STRING &fontname, PAGE_RES *page_res)
Definition: applybox.cpp:803
bool noise_outlines(TWERD *word)
Definition: docqual.cpp:980
bool TestNewNormalization(int original_misfits, float baseline_shift, float new_x_ht, WERD_RES *word, BLOCK *block, ROW *row)
Definition: control.cpp:1519
bool init_tesseract_lang_data(const char *arg0, const char *textbase, const char *language, OcrEngineMode oem, char **configs, int configs_size, const GenericVector< STRING > *vars_vec, const GenericVector< STRING > *vars_values, bool set_only_init_params, TessdataManager *mgr)
Definition: tessedit.cpp:79
bool digit_or_numeric_punct(WERD_RES *word, int char_position)
Definition: fixspace.cpp:370
void quality_based_rejection(PAGE_RES_IT &page_res_it, bool good_quality_doc)
Definition: docqual.cpp:138
int16_t safe_dict_word(const WERD_RES *werd_res)
Definition: reject.cpp:608
double tessedit_whole_wd_rej_row_percent
int16_t failure_count(WERD_RES *word)
Definition: docqual.cpp:968
void recognize_page(STRING &image_name)
void classify_word_pass1(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
Definition: control.cpp:1401
double tessedit_reject_row_percent
bool word_display(PAGE_RES_IT *pr_it)
Definition: pgedit.cpp:740
Tesseract * get_sub_lang(int index) const
bool word_bln_display(PAGE_RES_IT *pr_it)
Definition: pgedit.cpp:708
bool tessedit_resegment_from_line_boxes
void convert_bad_unlv_chs(WERD_RES *word_res)
Definition: docqual.cpp:659
bool SubAndSuperscriptFix(WERD_RES *word_res)
int16_t count_alphas(const WERD_CHOICE &word)
Definition: output.cpp:366
int scaled_factor() const
float ClassifyBlobAsWord(int pass_n, PAGE_RES_IT *pr_it, C_BLOB *blob, STRING *best_str, float *c2)
Definition: control.cpp:1270
void set_done(WERD_RES *word, int16_t pass)
int RetryWithLanguage(const WordData &word_data, WordRecognizer recognizer, bool debug, WERD_RES **in_word, PointerVector< WERD_RES > *best_words)
Definition: control.cpp:904
void write_results(PAGE_RES_IT &page_res_it, char newline_type, bool force_eol)
Definition: output.cpp:98
void process_selected_words(PAGE_RES *page_res, TBOX &selection_box, bool(tesseract::Tesseract::*word_processor)(PAGE_RES_IT *pr_it))
Definition: pagewalk.cpp:30
void PrepareForTessOCR(BLOCK_LIST *block_list, Tesseract *osd_tess, OSResults *osr)
bool word_set_display(PAGE_RES_IT *pr_it)
Definition: pgedit.cpp:928
PAGE_RES * SetupApplyBoxes(const GenericVector< TBOX > &boxes, BLOCK_LIST *block_list)
Definition: applybox.cpp:207
void dictionary_correction_pass(PAGE_RES *page_res)
Definition: control.cpp:2093
bool non_0_digit(const UNICHARSET &ch_set, UNICHAR_ID unichar_id)
Definition: reject.cpp:790
void break_noisiest_blob_word(WERD_RES_LIST &words)
Definition: fixspace.cpp:642
Pix * pix_original() const
bool check_debug_pt(WERD_RES *word, int location)
Definition: control.cpp:1849
int16_t fp_eval_word_spacing(WERD_RES_LIST &word_res_list)
Definition: fixspace.cpp:857
double rej_whole_of_mostly_reject_word_fract
void set_pix_thresholds(Pix *thresholds)
void recog_word_recursive(WERD_RES *word)
Definition: tfacepp.cpp:104
UNICHAR_ID get_rep_char(WERD_RES *word)
Definition: output.cpp:251
void word_char_quality(WERD_RES *word, ROW *row, int16_t *match_count, int16_t *accepted_match_count)
Definition: docqual.cpp:92
double textord_tabfind_aligned_gap_fraction
void PreenXHeights(BLOCK_LIST *block_list)
Definition: applybox.cpp:181
void tess_add_doc_word(WERD_CHOICE *word_choice)
Definition: tessbox.cpp:72
void flip_hyphens(WERD_RES *word)
Definition: reject.cpp:617
bool word_dumper(PAGE_RES_IT *pr_it)
Definition: pgedit.cpp:904
void TrainFromBoxes(const GenericVector< TBOX > &boxes, const GenericVector< STRING > &texts, BLOCK_LIST *block_list, DocumentData *training_data)
Definition: linerec.cpp:81
int init_tesseract(const char *datapath, const char *language, OcrEngineMode oem)
void SetupWordScripts(BLOCK_LIST *blocks)
int16_t eval_word_spacing(WERD_RES_LIST &word_res_list)
Definition: fixspace.cpp:266
bool FindSegmentation(const GenericVector< UNICHAR_ID > &target_text, WERD_RES *word_res)
Definition: applybox.cpp:561
bool word_blank_and_set_display(PAGE_RES_IT *pr_its)
Definition: pgedit.cpp:696
ImageData * GetRectImage(const TBOX &box, const BLOCK &block, int padding, TBOX *revised_box) const
Definition: linerec.cpp:170
int init_tesseract_lm(const char *arg0, const char *textbase, const char *language, TessdataManager *mgr)
Definition: tessedit.cpp:452
void set_source_resolution(int ppi)
void CorrectClassifyWords(PAGE_RES *page_res)
Definition: applybox.cpp:776
void MaximallyChopWord(const GenericVector< TBOX > &boxes, BLOCK *block, ROW *row, WERD_RES *word_res)
Definition: applybox.cpp:243
char * tessedit_write_params_to_file
void font_recognition_pass(PAGE_RES *page_res)
Definition: control.cpp:2037
bool ReassignDiacritics(int pass, PAGE_RES_IT *pr_it, bool *make_next_word_fuzzy)
Definition: control.cpp:945
void unrej_good_chs(WERD_RES *word, ROW *row)
Definition: docqual.cpp:115
double superscript_scaledown_ratio
void debug_word(PAGE_RES *page_res, const TBOX &selection_box)
Definition: pgedit.cpp:665
void pgeditor_main(int width, int height, PAGE_RES *page_res)
Definition: pgedit.cpp:378
void ambigs_classify_and_output(const char *label, PAGE_RES_IT *pr_it, FILE *output_file)
void reject_I_1_L(WERD_RES *word)
Definition: reject.cpp:194
void reject_mostly_rejects(WERD_RES *word)
Definition: reject.cpp:574
bool potential_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level, bool ok_dict_word)
Definition: docqual.cpp:541
bool BelievableSuperscript(bool debug, const WERD_RES &word, float certainty_threshold, int *left_ok, int *right_ok) const
bool AnyTessLang() const
void blob_feature_display(PAGE_RES *page_res, const TBOX &selection_box)
Definition: pgedit.cpp:943
const Textord & textord() const
bool textord_tabfind_force_vertical_text
void ReportFailedBox(int boxfile_lineno, TBOX box, const char *box_ch, const char *err_msg)
Definition: applybox.cpp:768
bool TrainLineRecognizer(const STRING &input_imagename, const STRING &output_basename, BLOCK_LIST *block_list)
Definition: linerec.cpp:44
bool ProcessTargetWord(const TBOX &word_box, const TBOX &target_word_box, const char *word_config, int pass)
Definition: control.cpp:120
void AssignDiacriticsToOverlappingBlobs(const GenericVector< C_OUTLINE * > &outlines, int pass, WERD *real_word, PAGE_RES_IT *pr_it, GenericVector< bool > *word_wanted, GenericVector< bool > *overlapped_any_blob, GenericVector< C_BLOB * > *target_blobs)
Definition: control.cpp:1011
WERD_RES * TrySuperscriptSplits(int num_chopped_leading, float leading_certainty, ScriptPos leading_pos, int num_chopped_trailing, float trailing_certainty, ScriptPos trailing_pos, WERD_RES *word, bool *is_good, int *retry_leading, int *retry_trailing)
char * ok_repeated_ch_non_alphanum_wds
bool RunOldFixXht(WERD_RES *word, BLOCK *block, ROW *row)
bool word_contains_non_1_digit(const char *word, const char *word_lengths)
Definition: reject.cpp:510
bool terrible_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level)
Definition: docqual.cpp:503
void do_re_display(bool(tesseract::Tesseract::*word_painter)(PAGE_RES_IT *pr_it))
Definition: pgedit.cpp:349
bool tessedit_preserve_blk_rej_perfect_wds
int CountMisfitTops(WERD_RES *word_res)
Definition: fixxht.cpp:70
void SearchWords(PointerVector< WERD_RES > *words)
Definition: linerec.cpp:259
int16_t word_blob_quality(WERD_RES *word, ROW *row)
Definition: docqual.cpp:60
bool TrainedXheightFix(WERD_RES *word, BLOCK *block, ROW *row)
Definition: control.cpp:1485
void join_words(WERD_RES *word, WERD_RES *word2, BlamerBundle *orig_bb) const
Definition: tfacepp.cpp:234
bool word_adaptable(WERD_RES *word, uint16_t mode)
Definition: adaptions.cpp:34
bool repeated_nonalphanum_wd(WERD_RES *word, ROW *row)
Definition: reject.cpp:583
void set_word_fonts(WERD_RES *word)
Definition: control.cpp:1962
PAGE_RES * ApplyBoxes(const STRING &fname, bool find_segmentation, BLOCK_LIST *block_list)
Definition: applybox.cpp:109
void set_pix_original(Pix *original_pix)
void match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK *block)
Definition: fixspace.cpp:223
CRUNCH_MODE word_deletable(WERD_RES *word, int16_t &delete_mode)
Definition: docqual.cpp:897
void ParseLanguageString(const char *lang_str, GenericVector< STRING > *to_load, GenericVector< STRING > *not_to_load)
Definition: tessedit.cpp:254
void nn_match_word(WERD_RES *word, ROW *row)
const FCOORD & reskew() const
void fix_fuzzy_spaces(ETEXT_DESC *monitor, int32_t word_count, PAGE_RES *page_res)
Definition: fixspace.cpp:75
bool AnyLSTMLang() const
double tessedit_reject_block_percent
bool tess_acceptable_word(WERD_RES *word)
Definition: tessbox.cpp:62
bool right_to_left() const
void script_pos_pass(PAGE_RES *page_res)
Definition: control.cpp:734
void nn_recover_rejects(WERD_RES *word, ROW *row)
bool RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT *pr_it, GenericVector< WordData > *words)
Definition: control.cpp:213
void PrerecAllWordsPar(const GenericVector< WordData > &words)
Definition: par_control.cpp:38
int16_t count_outline_errs(char c, int16_t outline_count)
Definition: docqual.cpp:126
void flip_0O(WERD_RES *word)
Definition: reject.cpp:674
int source_resolution() const
void unrej_good_quality_words(PAGE_RES_IT &page_res_it)
Definition: docqual.cpp:160
void blamer_pass(PAGE_RES *page_res)
Definition: control.cpp:710
void classify_word_pass2(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
Definition: control.cpp:1572
void AssignDiacriticsToNewBlobs(const GenericVector< C_OUTLINE * > &outlines, int pass, WERD *real_word, PAGE_RES_IT *pr_it, GenericVector< bool > *word_wanted, GenericVector< C_BLOB * > *target_blobs)
Definition: control.cpp:1064
void make_reject_map(WERD_RES *word, ROW *row, int16_t pass)
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
void recog_word(WERD_RES *word)
Definition: tfacepp.cpp:40
float ClassifyBlobPlusOutlines(const GenericVector< bool > &ok_outlines, const GenericVector< C_OUTLINE * > &outlines, int pass_n, PAGE_RES_IT *pr_it, C_BLOB *blob, STRING *best_str)
Definition: control.cpp:1226
double tessedit_good_doc_still_rowrej_wd
void ReportXhtFixResult(bool accept_new_word, float new_x_ht, WERD_RES *word, WERD_RES *new_word)
Definition: control.cpp:1462
Definition: blobs.h:284
Definition: blobs.h:418
Definition: ocrblock.h:31
Definition: ocrrow.h:37
Definition: points.h:189
Definition: rect.h:34
Definition: werd.h:56
Definition: strngs.h:45