23 #include "allheaders.h"
32 #include "config_auto.h"
39 "Take segmentation and labeling from box file",
41 BOOL_MEMBER(tessedit_resegment_from_line_boxes, false,
42 "Conversion of word/line box file to char box file",
45 "Generate training data from boxed chars", this->params()),
47 "Generate more boxes from boxed chars", this->params()),
49 "Dump intermediate images made during page segmentation",
54 "Page seg mode: 0=osd only, 1=auto+osd, 2=auto, 3=col, 4=block,"
55 " 5=line, 6=word, 7=char"
56 " (Values from PageSegMode enum in publictypes.h)",
59 "Which OCR engine(s) to run (Tesseract, Cube, both)."
60 " Defaults to loading and running only Tesseract"
61 " (no Cube,no combiner)."
62 " Values from OcrEngineMode enum in tesseractclass.h)",
65 "Blacklist of chars not to recognize", this->params()),
67 "Whitelist of chars to recognize", this->params()),
69 "Perform training for ambiguities", this->params()),
72 "Whether to use the top-line splitting process for Devanagari "
73 "documents while performing page-segmentation.", this->params()),
76 "Whether to use the top-line splitting process for Devanagari "
77 "documents while performing ocr.", this->params()),
79 "Write all parameters to the given file.", this->params()),
81 "Adapt to words that contain "
82 " a character composed form fragments", this->params()),
83 BOOL_MEMBER(tessedit_adaption_debug, false,
"Generate and print debug"
84 " information for adaption", this->params()),
85 INT_MEMBER(bidi_debug, 0,
"Debug level for BiDi", this->params()),
86 INT_MEMBER(applybox_debug, 1,
"Debug level", this->params()),
88 "Page number to apply boxes from", this->params()),
89 STRING_MEMBER(applybox_exposure_pattern,
".exp",
"Exposure value follows"
90 " this pattern in the image filename. The name of the image"
91 " files are expected to be in the form"
92 " [lang].[fontname].exp[num].tif", this->params()),
93 BOOL_MEMBER(applybox_learn_chars_and_char_frags_mode, false,
94 "Learn both character fragments (as is done in the"
95 " special low exposure mode) as well as unfragmented"
96 " characters.", this->params()),
97 BOOL_MEMBER(applybox_learn_ngrams_mode, false,
"Each bounding box"
98 " is assumed to contain ngrams. Only learn the ngrams"
99 " whose outlines overlap horizontally.", this->params()),
101 "Draw output words", this->params()),
103 "Call Tess to learn blobs", this->params()),
105 "Dump char choices", this->params()),
107 "Try to improve fuzzy spaces", this->params()),
109 "Dont bother with word plausibility", this->params()),
111 "Crunch double hyphens?", this->params()),
113 "Check/Correct x-height", this->params()),
115 "Add words to the document dictionary", this->params()),
117 "Output font info per char", this->params()),
119 "Block and Row stats", this->params()),
120 BOOL_MEMBER(tessedit_enable_bigram_correction, false,
121 "Enable correction based on the word bigram dictionary.",
124 "Amount of debug output for bigram correction.",
126 INT_MEMBER(debug_x_ht_level, 0,
"Reestimate debug", this->params()),
128 "Dump word pass/fail chk", this->params()),
130 "Leading punctuation", this->params()),
132 "1st Trailing punctuation", this->params()),
134 "2nd Trailing punctuation", this->params()),
136 "good_quality_doc lte rejection limit", this->params()),
138 "good_quality_doc gte good blobs limit", this->params()),
140 "good_quality_doc lte outline error limit", this->params()),
142 "good_quality_doc gte good char limit", this->params()),
143 INT_MEMBER(quality_min_initial_alphas_reqd, 2,
144 "alphas in a good word", this->params()),
146 "Use reject map to control Tesseract adaption", this->params()),
148 "Adaptation decision algorithm for tess", this->params()),
150 "Do minimal rejection on pass 1 output", this->params()),
152 "Test adaption criteria", this->params()),
154 "Log matcher activity", this->params()),
156 "Adaptation decision algorithm for tess", this->params()),
158 "Save the results of the recognition step (blob_choices)"
159 " within the corresponding WERD_CHOICE", this->params()),
160 BOOL_MEMBER(test_pt, false,
"Test for point", this->params()),
161 double_MEMBER(test_pt_x, 99999.99,
"xcoord", this->params()),
162 double_MEMBER(test_pt_y, 99999.99,
"ycoord", this->params()),
163 INT_MEMBER(paragraph_debug_level, 0,
"Print paragraph debug info.",
165 INT_MEMBER(cube_debug_level, 0,
"Print cube debug info.", this->params()),
166 STRING_MEMBER(outlines_odd,
"%| ",
"Non standard number of outlines",
169 "Non standard number of outlines", this->params()),
171 "Allow outline errs in unrejection?", this->params()),
173 "Reduce rejection on good docs", this->params()),
175 "Reject spaces?", this->params()),
177 "%rej allowed before rej whole doc", this->params()),
179 "%rej allowed before rej whole block", this->params()),
181 "%rej allowed before rej whole row", this->params()),
183 "Number of row rejects in whole word rejects"
184 "which prevents whole row rejection", this->params()),
185 BOOL_MEMBER(tessedit_preserve_blk_rej_perfect_wds, true,
186 "Only rej partially rejected words in block rejection",
188 BOOL_MEMBER(tessedit_preserve_row_rej_perfect_wds, true,
189 "Only rej partially rejected words in row rejection",
192 "Use word segmentation quality metric", this->params()),
194 "Use word segmentation quality metric", this->params()),
196 "Only preserve wds longer than this", this->params()),
198 "Apply row rejection to good docs", this->params()),
200 "rej good doc wd if more than this fraction rejected",
203 "Reject all bad quality wds", this->params()),
205 "Page stats", this->params()),
207 "Output data to debug file", this->params()),
209 "unrej potential with no chekcs", this->params()),
211 "good_quality_doc gte good char limit", this->params()),
213 "Mark v.bad words for tilde crunch", this->params()),
215 "Before word crunch?", this->params()),
216 BOOL_MEMBER(crunch_early_convert_bad_unlv_chs, false,
217 "Take out ~^ early?", this->params()),
219 "crunch rating lt this", this->params()),
220 BOOL_MEMBER(crunch_terrible_garbage, true,
"As it says", this->params()),
222 "crunch garbage cert lt this", this->params()),
224 "crunch garbage rating lt this", this->params()),
226 "POTENTIAL crunch rating lt this", this->params()),
228 "POTENTIAL crunch cert lt this", this->params()),
230 "POTENTIAL crunch garbage", this->params()),
232 "POTENTIAL crunch rating lt this", this->params()),
234 "POTENTIAL crunch cert lt this", this->params()),
236 "Del if word ht lt xht x this", this->params()),
238 "Del if word ht gt xht x this", this->params()),
240 "Del if word width lt xht x this", this->params()),
242 "Del if word gt xht x this above bl", this->params()),
244 "Del if word gt xht x this below bl", this->params()),
246 "Small if lt xht x this", this->params()),
248 "For adj length in rating per ch", this->params()),
250 "How many potential indicators needed", this->params()),
252 "Dont touch sensible strings", this->params()),
254 "Use acceptability in okstring", this->params()),
256 "Dont pot crunch sensible strings", this->params()),
258 "Fiddle alpha figures", this->params()),
260 "Dont crunch words with long lower case strings",
263 "Dont crunch words with long lower case strings",
266 "Crunch words with long repetitions", this->params()),
267 INT_MEMBER(crunch_debug, 0,
"As it says", this->params()),
269 "How many non-noise blbs either side?", this->params()),
271 "Small if lt xht x this", this->params()),
273 "Reward punctation joins", this->params()),
275 "What constitues done for spacing", this->params()),
277 "Contextual fixspace debug", this->params()),
279 "Punct. chs expected WITHIN numbers", this->params()),
281 "Max allowed deviation of blob top outside of font data",
284 "Min change in xht before actually trying it", this->params()),
285 BOOL_MEMBER(tessedit_write_block_separators, false,
286 "Write block separators in output", this->params()),
288 "Write repetition char code", this->params()),
290 "Write .unlv output file", this->params()),
292 "Write .html hOCR output file", this->params()),
294 "Output char for unidentified blobs", this->params()),
295 INT_MEMBER(suspect_level, 99,
"Suspect marker level", this->params()),
297 "Min suspect level for rejecting spaces", this->params()),
299 "Dont Suspect dict wds longer than this", this->params()),
301 "UNLV keep 1Il chars rejected", this->params()),
303 "Dont touch bad rating limit", this->params()),
305 "Accept good rating limit", this->params()),
307 "Only reject tess failures", this->params()),
309 "Dont reject ANYTHING", this->params()),
311 "Make output have exactly one word per WERD", this->params()),
313 "Dont reject ANYTHING AT ALL", this->params()),
315 "Force all rep chars the same", this->params()),
316 INT_MEMBER(tessedit_reject_mode, 0,
"Rejection algorithm", this->params()),
318 "Acceptance decision algorithm", this->params()),
320 "Adaption debug", this->params()),
322 "Contextual 0O O0 flips", this->params()),
324 "Aspect ratio dot/hyphen test", this->params()),
326 "Aspect ratio dot/hyphen test", this->params()),
328 "Use DOC dawg in 11l conf. detector", this->params()),
330 "Use dictword test", this->params()),
332 "Dont double check", this->params()),
334 "Individual rejection control", this->params()),
336 "Individual rejection control", this->params()),
338 "Individual rejection control", this->params()),
340 "Extend permuter check", this->params()),
342 "Extend permuter check", this->params()),
344 "if >this fract", this->params()),
346 "Rej blbs near image edge limit", this->params()),
348 "Allow NN to unrej", this->params()),
350 "Il1 conflict set", this->params()),
352 "Reject any x-ht lt or eq than this", this->params()),
354 "Output text with boxes", this->params()),
355 INT_MEMBER(tessedit_page_number, -1,
"-1 -> All pages"
356 " , else specifc page to process", this->params()),
358 "Capture the image from the IPE", this->params()),
359 BOOL_MEMBER(interactive_display_mode, false,
"Run interactively?",
361 STRING_MEMBER(file_type,
".tif",
"Filename extension", this->params()),
363 "According to dict_word", this->params()),
364 INT_MEMBER(tessdata_manager_debug_level, 0,
"Debug level for"
365 " TessdataManager functions.", this->params()),
367 "List of languages to load with this one", this->params()),
369 "Min acceptable orientation margin", this->params()),
370 BOOL_MEMBER(textord_tabfind_show_vlines, false,
"Debug line finding",
375 "Only initialize with the config file. Useful if the "
376 "instance is not going to be used for OCR but say only "
377 "for layout analysis.", this->params()),
378 BOOL_MEMBER(textord_equation_detect, false,
"Turn on equation detector",
380 backup_config_file_(
NULL),
384 source_resolution_(0),
386 right_to_left_(false),
391 most_recently_used_(this),
394 tess_cube_combiner_(
NULL),
403 if (cube_cntxt_ !=
NULL) {
407 if (tess_cube_combiner_ !=
NULL) {
408 delete tess_cube_combiner_;
409 tess_cube_combiner_ =
NULL;
414 pixDestroy(&pix_binary_);
415 pixDestroy(&cube_binary_);
416 pixDestroy(&pix_grey_);
417 pixDestroy(&scaled_color_);
423 for (
int i = 0; i < sub_langs_.
size(); ++i)
424 sub_langs_[i]->
Clear();
428 equ_detect_ = detector;
435 for (
int i = 0; i < sub_langs_.
size(); ++i) {
436 sub_langs_[i]->ResetAdaptiveClassifierInternal();
443 for (
int i = 0; i < sub_langs_.
size(); ++i) {
444 sub_langs_[i]->getDict().ResetDocumentDictionary();
453 for (
int i = 0; i < sub_langs_.
size(); ++i) {
454 sub_langs_[i]->unicharset.set_black_and_whitelist(
463 pixDestroy(&cube_binary_);
469 for (
int i = 0; i < sub_langs_.
size(); ++i) {
472 static_cast<inT32>(sub_langs_[i]->pageseg_devanagari_split_strategy));
473 if (pageseg_strategy > max_pageseg_strategy)
474 max_pageseg_strategy = pageseg_strategy;
476 pixDestroy(&sub_langs_[i]->cube_binary_);
477 sub_langs_[i]->cube_binary_ = pixClone(
pix_binary());
478 pixDestroy(&sub_langs_[i]->pix_binary_);
479 sub_langs_[i]->pix_binary_ = pixClone(
pix_binary());
485 if (splitter_.
Split(
true)) {
487 pixDestroy(&pix_binary_);
503 for (
int i = 0; i < sub_langs_.
size(); ++i) {
506 static_cast<inT32>(sub_langs_[i]->ocr_devanagari_split_strategy));
507 if (ocr_strategy > max_ocr_strategy)
508 max_ocr_strategy = ocr_strategy;
514 bool split_for_ocr = splitter_.
Split(
false);
517 pixDestroy(&pix_binary_);
518 pix_binary_ = pixClone(splitter_.
orig_pix());
523 BLOCK block(
"",
TRUE, 0, 0, 0, 0, pixGetWidth(pix_binary_),
524 pixGetHeight(pix_binary_));