1
1
/* *********************************************************************
2
2
* File: tesseractmain.cpp (Formerly tessedit.c)
3
3
* Description: Main program for merge of tess and editor.
4
- * Author: Ray Smith
5
- * Created: Tue Jan 07 15:21:46 GMT 1992
4
+ * Author: Ray Smith
5
+ * Created: Tue Jan 07 15:21:46 GMT 1992
6
6
*
7
7
* (C) Copyright 1992, Hewlett-Packard Ltd.
8
8
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -124,7 +124,7 @@ static void PrintHelpForPSM() {
124
124
" bypassing hacks that are Tesseract-specific.\n " ;
125
125
126
126
#ifdef DISABLED_LEGACY_ENGINE
127
- const char * disabled_osd_msg =
127
+ const char * disabled_osd_msg =
128
128
" \n NOTE: The OSD modes are currently disabled.\n " ;
129
129
printf (" %s%s" , msg, disabled_osd_msg);
130
130
#else
@@ -305,11 +305,11 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
305
305
} else if ((strcmp (argv[i], " --help-psm" ) == 0 )) {
306
306
PrintHelpForPSM ();
307
307
noocr = true ;
308
- #ifndef DISABLED_LEGACY_ENGINE
308
+ #ifndef DISABLED_LEGACY_ENGINE
309
309
} else if ((strcmp (argv[i], " --help-oem" ) == 0 )) {
310
310
PrintHelpForOEM ();
311
311
noocr = true ;
312
- #endif
312
+ #endif
313
313
} else if ((strcmp (argv[i], " -v" ) == 0 ) ||
314
314
(strcmp (argv[i], " --version" ) == 0 )) {
315
315
PrintVersionInfo ();
@@ -336,11 +336,11 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
336
336
*pagesegmode = static_cast <tesseract::PageSegMode>(atoi (argv[i + 1 ]));
337
337
++i;
338
338
} else if (strcmp (argv[i], " --oem" ) == 0 && i + 1 < argc) {
339
- #ifndef DISABLED_LEGACY_ENGINE
339
+ #ifndef DISABLED_LEGACY_ENGINE
340
340
int oem = atoi (argv[i + 1 ]);
341
341
checkArgValues (oem, " OEM" , tesseract::OEM_COUNT);
342
342
*enginemode = static_cast <tesseract::OcrEngineMode>(oem);
343
- #endif
343
+ #endif
344
344
++i;
345
345
} else if (strcmp (argv[i], " --print-parameters" ) == 0 ) {
346
346
noocr = true ;
@@ -464,14 +464,9 @@ int main(int argc, char** argv) {
464
464
ParseArgs (argc, argv, &lang, &image, &outputbase, &datapath, &list_langs,
465
465
&print_parameters, &vars_vec, &vars_values, &arg_i, &pagesegmode,
466
466
&enginemode);
467
- if (image == nullptr && !list_langs)
468
- return EXIT_SUCCESS;
469
467
470
- bool banner = false ;
471
- if (outputbase != nullptr && strcmp (outputbase, " -" ) &&
472
- strcmp (outputbase, " stdout" )) {
473
- banner = true ;
474
- }
468
+ if (image == nullptr && !list_langs && !print_parameters)
469
+ return EXIT_SUCCESS;
475
470
476
471
PERF_COUNT_START (" Tesseract:main" )
477
472
@@ -501,11 +496,11 @@ int main(int argc, char** argv) {
501
496
}
502
497
503
498
if (print_parameters) {
504
- FILE* fout = stdout;
505
- fprintf (stdout, " Tesseract parameters:\n " );
506
- api.PrintVariables (fout);
507
- api.End ();
508
- return EXIT_SUCCESS;
499
+ FILE* fout = stdout;
500
+ fprintf (stdout, " Tesseract parameters:\n " );
501
+ api.PrintVariables (fout);
502
+ api.End ();
503
+ return EXIT_SUCCESS;
509
504
}
510
505
511
506
FixPageSegMode (&api, pagesegmode);
@@ -553,20 +548,20 @@ int main(int argc, char** argv) {
553
548
554
549
#ifdef DISABLED_LEGACY_ENGINE
555
550
auto cur_psm = api.GetPageSegMode ();
556
- auto osd_warning = std::string (" " );
557
- if (cur_psm == tesseract::PSM_OSD_ONLY) {
558
- const char * disabled_osd_msg =
551
+ auto osd_warning = std::string (" " );
552
+ if (cur_psm == tesseract::PSM_OSD_ONLY) {
553
+ const char * disabled_osd_msg =
559
554
" \n ERROR: The page segmentation mode 0 (OSD Only) is currently disabled.\n\n " ;
560
555
fprintf (stderr, " %s" , disabled_osd_msg);
561
556
return EXIT_FAILURE;
562
557
} else if (cur_psm == tesseract::PSM_AUTO_OSD) {
563
558
api.SetPageSegMode (tesseract::PSM_AUTO);
564
- osd_warning +=
559
+ osd_warning +=
565
560
" \n Warning: The page segmentation mode 1 (Auto+OSD) is currently disabled. "
566
561
" Using PSM 3 (Auto) instead.\n\n " ;
567
562
} else if (tesseract::PSM_SPARSE_TEXT_OSD) {
568
563
api.SetPageSegMode (tesseract::PSM_SPARSE_TEXT);
569
- osd_warning +=
564
+ osd_warning +=
570
565
" \n Warning: The page segmentation mode 12 (Sparse text + OSD) is currently disabled. "
571
566
" Using PSM 11 (Sparse text) instead.\n\n " ;
572
567
}
@@ -581,13 +576,19 @@ int main(int argc, char** argv) {
581
576
PreloadRenderers (&api, &renderers, pagesegmode, outputbase);
582
577
}
583
578
579
+ bool banner = false ;
580
+ if (outputbase != nullptr && strcmp (outputbase, " -" ) &&
581
+ strcmp (outputbase, " stdout" )) {
582
+ banner = true ;
583
+ }
584
+
584
585
if (!renderers.empty ()) {
585
586
if (banner) PrintBanner ();
586
- #ifdef DISABLED_LEGACY_ENGINE
587
+ #ifdef DISABLED_LEGACY_ENGINE
587
588
if (!osd_warning.empty ()) {
588
589
fprintf (stderr, " %s" ,osd_warning.c_str ());
589
590
}
590
- #endif
591
+ #endif
591
592
bool succeed = api.ProcessPages (image, nullptr , 0 , renderers[0 ]);
592
593
if (!succeed) {
593
594
fprintf (stderr, " Error during processing.\n " );
0 commit comments