@@ -51,7 +51,7 @@ static void Win32WarningHandler(const char* module, const char* fmt,
51
51
52
52
#endif /* HAVE_TIFFIO_H && _WIN32 */
53
53
54
- void PrintVersionInfo () {
54
+ static void PrintVersionInfo () {
55
55
char * versionStrP;
56
56
57
57
printf (" tesseract %s\n " , tesseract::TessBaseAPI::Version ());
@@ -103,17 +103,7 @@ void PrintVersionInfo() {
103
103
if (SIMDDetect::IsSSEAvailable ()) printf (" Found SSE\n " );
104
104
}
105
105
106
- void PrintUsage (const char * program) {
107
- printf (
108
- " Usage:\n "
109
- " %s --help | --help-psm | --help-oem | --version\n "
110
- " %s --list-langs [--tessdata-dir PATH]\n "
111
- " %s --print-parameters [options...] [configfile...]\n "
112
- " %s imagename|stdin outputbase|stdout [options...] [configfile...]\n " ,
113
- program, program, program, program);
114
- }
115
-
116
- void PrintHelpForPSM () {
106
+ static void PrintHelpForPSM () {
117
107
const char * msg =
118
108
" Page segmentation modes:\n "
119
109
" 0 Orientation and script detection (OSD) only.\n "
@@ -131,26 +121,30 @@ void PrintHelpForPSM() {
131
121
" particular order.\n "
132
122
" 12 Sparse text with OSD.\n "
133
123
" 13 Raw line. Treat the image as a single text line,\n "
134
- " \t\t\t bypassing hacks that are Tesseract-specific.\n " ;
124
+ " bypassing hacks that are Tesseract-specific.\n " ;
135
125
136
126
printf (" %s" , msg);
137
127
}
138
128
139
- void PrintHelpForOEM () {
129
+ static void PrintHelpForOEM () {
140
130
const char * msg =
141
131
" OCR Engine modes:\n "
142
- " 0 Original Tesseract only (unsupported) .\n "
132
+ " 0 Legacy Tesseract only.\n "
143
133
" 1 Neural nets LSTM only.\n "
144
- " 2 Tesseract + LSTM (unsupported) .\n "
134
+ " 2 Legacy + LSTM Tesseract .\n "
145
135
" 3 Default, based on what is available.\n " ;
146
136
147
137
printf (" %s" , msg);
148
138
}
149
139
150
- void PrintHelpMessage (const char * program) {
151
- PrintUsage (program);
152
-
153
- const char * ocr_options =
140
+ static void PrintHelpExtra (const char * program) {
141
+ printf (
142
+ " Usage:\n "
143
+ " %s --help | --help-extra | --help-psm | --help-oem | --version\n "
144
+ " %s --list-langs [--tessdata-dir PATH]\n "
145
+ " %s --print-parameters [options...] [configfile...]\n "
146
+ " %s imagename|imagelist|stdin outputbase|stdout [options...] [configfile...]\n "
147
+ " \n "
154
148
" OCR options:\n "
155
149
" --tessdata-dir PATH Specify the location of tessdata path.\n "
156
150
" --user-words PATH Specify the location of user words file.\n "
@@ -160,26 +154,50 @@ void PrintHelpMessage(const char* program) {
160
154
" Multiple -c arguments are allowed.\n "
161
155
" --psm NUM Specify page segmentation mode.\n "
162
156
" --oem NUM Specify OCR Engine mode.\n "
163
- " NOTE: These options must occur before any configfile.\n " ;
157
+ " NOTE: These options must occur before any configfile.\n "
158
+ " \n " ,
159
+ program, program, program, program
160
+ );
164
161
165
- printf (" \n %s\n " , ocr_options);
166
162
PrintHelpForPSM ();
163
+ printf (" \n " );
167
164
PrintHelpForOEM ();
168
165
169
- const char * single_options =
166
+ printf (
167
+ " \n "
170
168
" Single options:\n "
171
- " -h, --help Show this help message.\n "
169
+ " -h, --help Show minimal help message.\n "
170
+ " --help-extra Show extra help for advanced users.\n "
172
171
" --help-psm Show page segmentation modes.\n "
173
172
" --help-oem Show OCR Engine modes.\n "
174
173
" -v, --version Show version information.\n "
175
174
" --list-langs List available languages for tesseract engine.\n "
176
- " --print-parameters Print tesseract parameters.\n " ;
175
+ " --print-parameters Print tesseract parameters.\n "
176
+ );
177
+ }
177
178
178
- printf (" \n %s" , single_options);
179
+ static void PrintHelpMessage (const char * program) {
180
+ printf (
181
+ " Usage:\n "
182
+ " %s --help | --help-extra | --version\n "
183
+ " %s --list-langs\n "
184
+ " %s imagename outputbase [options...] [configfile...]\n "
185
+ " \n "
186
+ " OCR options:\n "
187
+ " -l LANG[+LANG] Specify language(s) used for OCR.\n "
188
+ " NOTE: These options must occur before any configfile.\n "
189
+ " \n "
190
+ " Single options:\n "
191
+ " --help Show this help message.\n "
192
+ " --help-extra Show extra help for advanced users.\n "
193
+ " --version Show version information.\n "
194
+ " --list-langs List available languages for tesseract engine.\n " ,
195
+ program, program, program
196
+ );
179
197
}
180
198
181
- void SetVariablesFromCLArgs (tesseract::TessBaseAPI* api, int argc,
182
- char ** argv) {
199
+ static void SetVariablesFromCLArgs (tesseract::TessBaseAPI* api, int argc,
200
+ char ** argv) {
183
201
char opt1[256 ], opt2[255 ];
184
202
for (int i = 0 ; i < argc; i++) {
185
203
if (strcmp (argv[i], " -c" ) == 0 && i + 1 < argc) {
@@ -202,7 +220,7 @@ void SetVariablesFromCLArgs(tesseract::TessBaseAPI* api, int argc,
202
220
}
203
221
}
204
222
205
- void PrintLangsList (tesseract::TessBaseAPI* api) {
223
+ static void PrintLangsList (tesseract::TessBaseAPI* api) {
206
224
GenericVector<STRING> languages;
207
225
api->GetAvailableLanguagesAsVector (&languages);
208
226
printf (" List of available languages (%d):\n " , languages.size ());
@@ -213,7 +231,7 @@ void PrintLangsList(tesseract::TessBaseAPI* api) {
213
231
api->End ();
214
232
}
215
233
216
- void PrintBanner () {
234
+ static void PrintBanner () {
217
235
tprintf (" Tesseract Open Source OCR Engine v%s with Leptonica\n " ,
218
236
tesseract::TessBaseAPI::Version ());
219
237
}
@@ -232,27 +250,28 @@ void PrintBanner() {
232
250
* It would be simpler if we could set the value before Init,
233
251
* but that doesn't work.
234
252
*/
235
- void FixPageSegMode (tesseract::TessBaseAPI* api,
236
- tesseract::PageSegMode pagesegmode) {
253
+ static void FixPageSegMode (tesseract::TessBaseAPI* api,
254
+ tesseract::PageSegMode pagesegmode) {
237
255
if (api->GetPageSegMode () == tesseract::PSM_SINGLE_BLOCK)
238
256
api->SetPageSegMode (pagesegmode);
239
257
}
240
258
241
- void checkArgValues (int arg, const char * mode, int count) {
259
+ static void checkArgValues (int arg, const char * mode, int count) {
242
260
if (arg >= count || arg < 0 ) {
243
- printf (" Invalid %s value, please enter a number between 0-%d" , mode, count - 1 );
244
- exit (0 );
261
+ printf (" Invalid %s value, please enter a number between 0-%d\n " , mode, count - 1 );
262
+ exit (0 );
245
263
}
246
264
}
247
265
248
266
// NOTE: arg_i is used here to avoid ugly *i so many times in this function
249
- void ParseArgs (const int argc, char ** argv, const char ** lang,
250
- const char ** image, const char ** outputbase,
251
- const char ** datapath, bool * list_langs, bool * print_parameters,
252
- GenericVector<STRING>* vars_vec,
253
- GenericVector<STRING>* vars_values, int * arg_i,
254
- tesseract::PageSegMode* pagesegmode,
255
- tesseract::OcrEngineMode* enginemode) {
267
+ static void ParseArgs (const int argc, char ** argv, const char ** lang,
268
+ const char ** image, const char ** outputbase,
269
+ const char ** datapath,
270
+ bool * list_langs, bool * print_parameters,
271
+ GenericVector<STRING>* vars_vec,
272
+ GenericVector<STRING>* vars_values, int * arg_i,
273
+ tesseract::PageSegMode* pagesegmode,
274
+ tesseract::OcrEngineMode* enginemode) {
256
275
if (argc == 1 ) {
257
276
PrintHelpMessage (argv[0 ]);
258
277
exit (0 );
@@ -263,6 +282,10 @@ void ParseArgs(const int argc, char** argv, const char** lang,
263
282
PrintHelpMessage (argv[0 ]);
264
283
exit (0 );
265
284
}
285
+ if (strcmp (argv[1 ], " --help-extra" ) == 0 ) {
286
+ PrintHelpExtra (argv[0 ]);
287
+ exit (0 );
288
+ }
266
289
if ((strcmp (argv[1 ], " --help-psm" ) == 0 )) {
267
290
PrintHelpForPSM ();
268
291
exit (0 );
@@ -310,11 +333,6 @@ void ParseArgs(const int argc, char** argv, const char** lang,
310
333
} else if (strcmp (argv[i], " --oem" ) == 0 && i + 1 < argc) {
311
334
int oem = atoi (argv[i + 1 ]);
312
335
checkArgValues (oem, " OEM" , tesseract::OEM_COUNT);
313
- if (oem == tesseract::OEM_TESSERACT_ONLY ||
314
- oem == tesseract::OEM_TESSERACT_LSTM_COMBINED) {
315
- printf (" Legacy OCR Engine is not supported anymore.\n " );
316
- exit (2 );
317
- }
318
336
*enginemode = static_cast <tesseract::OcrEngineMode>(oem);
319
337
++i;
320
338
} else if (strcmp (argv[i], " --print-parameters" ) == 0 ) {
@@ -344,7 +362,7 @@ void ParseArgs(const int argc, char** argv, const char** lang,
344
362
}
345
363
}
346
364
347
- void PreloadRenderers (
365
+ static void PreloadRenderers (
348
366
tesseract::TessBaseAPI* api,
349
367
tesseract::PointerVector<tesseract::TessResultRenderer>* renderers,
350
368
tesseract::PageSegMode pagesegmode, const char * outputbase) {
0 commit comments