@@ -90,7 +90,7 @@ void PrintVersionInfo() {
90
90
void PrintUsage (const char * program) {
91
91
printf (
92
92
" Usage:\n "
93
- " %s --help | --help-psm | --version\n "
93
+ " %s --help | --help-psm | --help-oem | -- version\n "
94
94
" %s --list-langs [--tessdata-dir PATH]\n "
95
95
" %s --print-parameters [options...] [configfile...]\n "
96
96
" %s imagename|stdin outputbase|stdout [options...] [configfile...]\n " ,
@@ -120,6 +120,18 @@ void PrintHelpForPSM() {
120
120
printf (" %s" , msg);
121
121
}
122
122
123
+ void PrintHelpForOEM () {
124
+ const char * msg =
125
+ " OCR Engine modes:\n "
126
+ " 0 Original Tesseract only.\n "
127
+ " 1 Cube only.\n "
128
+ " 2 Tesseract + cube.\n "
129
+ " 3 Default, based on what is available.\n "
130
+ " 4 Neural nets (LSTM) only.\n " ;
131
+
132
+ printf (" %s" , msg);
133
+ }
134
+
123
135
void PrintHelpMessage (const char * program) {
124
136
PrintUsage (program);
125
137
@@ -132,15 +144,18 @@ void PrintHelpMessage(const char* program) {
132
144
" -c VAR=VALUE Set value for config variables.\n "
133
145
" Multiple -c arguments are allowed.\n "
134
146
" -psm NUM Specify page segmentation mode.\n "
147
+ " -oem NUM Specify OCR Engine mode.\n "
135
148
" NOTE: These options must occur before any configfile.\n " ;
136
149
137
150
printf (" \n %s\n " , ocr_options);
138
151
PrintHelpForPSM ();
152
+ PrintHelpForOEM ();
139
153
140
154
const char * single_options =
141
155
" Single options:\n "
142
156
" -h, --help Show this help message.\n "
143
157
" --help-psm Show page segmentation modes.\n "
158
+ " --help-oem Show OCR Engine modes.\n "
144
159
" -v, --version Show version information.\n "
145
160
" --list-langs List available languages for tesseract engine.\n "
146
161
" --print-parameters Print tesseract parameters to stdout.\n " ;
@@ -214,7 +229,8 @@ void ParseArgs(const int argc, char** argv, const char** lang,
214
229
const char ** datapath, bool * list_langs, bool * print_parameters,
215
230
GenericVector<STRING>* vars_vec,
216
231
GenericVector<STRING>* vars_values, int * arg_i,
217
- tesseract::PageSegMode* pagesegmode) {
232
+ tesseract::PageSegMode* pagesegmode,
233
+ tesseract::OcrEngineMode* enginemode) {
218
234
if (argc == 1 ) {
219
235
PrintHelpMessage (argv[0 ]);
220
236
exit (0 );
@@ -229,6 +245,10 @@ void ParseArgs(const int argc, char** argv, const char** lang,
229
245
PrintHelpForPSM ();
230
246
exit (0 );
231
247
}
248
+ if ((strcmp (argv[1 ], " --help-oem" ) == 0 )) {
249
+ PrintHelpForOEM ();
250
+ exit (0 );
251
+ }
232
252
if ((strcmp (argv[1 ], " -v" ) == 0 ) || (strcmp (argv[1 ], " --version" ) == 0 )) {
233
253
PrintVersionInfo ();
234
254
exit (0 );
@@ -258,6 +278,9 @@ void ParseArgs(const int argc, char** argv, const char** lang,
258
278
} else if (strcmp (argv[i], " -psm" ) == 0 && i + 1 < argc) {
259
279
*pagesegmode = static_cast <tesseract::PageSegMode>(atoi (argv[i + 1 ]));
260
280
++i;
281
+ } else if (strcmp (argv[i], " -oem" ) == 0 && i + 1 < argc) {
282
+ *enginemode = static_cast <tesseract::OcrEngineMode>(atoi (argv[i + 1 ]));
283
+ ++i;
261
284
} else if (strcmp (argv[i], " --print-parameters" ) == 0 ) {
262
285
noocr = true ;
263
286
*print_parameters = true ;
@@ -355,6 +378,7 @@ int main(int argc, char** argv) {
355
378
bool print_parameters = false ;
356
379
int arg_i = 1 ;
357
380
tesseract::PageSegMode pagesegmode = tesseract::PSM_AUTO;
381
+ tesseract::OcrEngineMode enginemode = tesseract::OEM_DEFAULT;
358
382
/* main() calls functions like ParseArgs which call exit().
359
383
* This results in memory leaks if vars_vec and vars_values are
360
384
* declared as auto variables (destructor is not called then). */
@@ -367,7 +391,8 @@ int main(int argc, char** argv) {
367
391
#endif /* HAVE_TIFFIO_H && _WIN32 */
368
392
369
393
ParseArgs (argc, argv, &lang, &image, &outputbase, &datapath, &list_langs,
370
- &print_parameters, &vars_vec, &vars_values, &arg_i, &pagesegmode);
394
+ &print_parameters, &vars_vec, &vars_values, &arg_i, &pagesegmode,
395
+ &enginemode);
371
396
372
397
bool banner = false ;
373
398
if (outputbase != NULL && strcmp (outputbase, " -" ) &&
@@ -380,9 +405,8 @@ int main(int argc, char** argv) {
380
405
381
406
api.SetOutputName (outputbase);
382
407
383
- int init_failed =
384
- api.Init (datapath, lang, tesseract::OEM_DEFAULT, &(argv[arg_i]),
385
- argc - arg_i, &vars_vec, &vars_values, false );
408
+ int init_failed = api.Init (datapath, lang, enginemode, &(argv[arg_i]),
409
+ argc - arg_i, &vars_vec, &vars_values, false );
386
410
if (init_failed) {
387
411
fprintf (stderr, " Could not initialize tesseract.\n " );
388
412
exit (1 );
0 commit comments