605 const char* lang =
nullptr;
606 const char* image =
nullptr;
607 const char* outputbase =
nullptr;
608 const char* datapath =
nullptr;
609 bool list_langs =
false;
610 bool print_parameters =
false;
614 #ifdef DISABLED_LEGACY_ENGINE
627 setMsgSeverity(L_SEVERITY_ERROR);
630 #if defined(HAVE_TIFFIO_H) && defined(_WIN32)
632 TIFFSetErrorHandler(Win32ErrorHandler);
633 TIFFSetWarningHandler(Win32WarningHandler);
634 #endif // HAVE_TIFFIO_H && _WIN32
636 ParseArgs(argc, argv, &lang, &image, &outputbase, &datapath, &dpi,
637 &list_langs, &print_parameters, &vars_vec, &vars_values, &arg_i,
638 &pagesegmode, &enginemode);
640 if (lang ==
nullptr) {
645 if (image ==
nullptr && !list_langs && !print_parameters)
658 const int init_failed = api.
Init(datapath, lang, enginemode, &(argv[arg_i]),
659 argc - arg_i, &vars_vec, &vars_values,
false);
661 SetVariablesFromCLArgs(&api, argc, argv);
667 PrintLangsList(&api);
672 fprintf(stderr,
"Could not initialize tesseract.\n");
676 if (print_parameters) {
678 fprintf(stdout,
"Tesseract parameters:\n");
684 FixPageSegMode(&api, pagesegmode);
687 char dpi_string[255];
688 snprintf(dpi_string, 254,
"%d", dpi);
693 int ret_val = EXIT_SUCCESS;
695 Pix* pixs = pixRead(image);
697 fprintf(stderr,
"Leptonica can't process input file: %s\n", image);
712 it->
Orientation(&orientation, &direction, &order, &deskew_angle);
714 "Orientation: %d\nWritingDirection: %d\nTextlineOrder: %d\n"
715 "Deskew angle: %.4f\n",
716 orientation, direction, order, deskew_angle);
718 ret_val = EXIT_FAILURE;
731 bool in_training_mode =
737 #ifdef DISABLED_LEGACY_ENGINE
741 const char* disabled_osd_msg =
742 "\nERROR: The page segmentation mode 0 (OSD Only) is currently disabled.\n\n";
743 fprintf(stderr,
"%s", disabled_osd_msg);
748 "\nWarning: The page segmentation mode 1 (Auto+OSD) is currently disabled. "
749 "Using PSM 3 (Auto) instead.\n\n";
753 "\nWarning: The page segmentation mode 12 (Sparse text + OSD) is currently disabled. "
754 "Using PSM 11 (Sparse text) instead.\n\n";
756 #endif // def DISABLED_LEGACY_ENGINE
761 if (in_training_mode) {
763 }
else if (outputbase !=
nullptr) {
764 PreloadRenderers(&api, &renderers, pagesegmode, outputbase);
768 if (outputbase !=
nullptr && strcmp(outputbase,
"-") &&
769 strcmp(outputbase,
"stdout")) {
773 if (!renderers.
empty()) {
774 if (banner) PrintBanner();
775 #ifdef DISABLED_LEGACY_ENGINE
776 if (!osd_warning.empty()) {
777 fprintf(stderr,
"%s",osd_warning.c_str());
780 bool succeed = api.
ProcessPages(image,
nullptr, 0, renderers[0]);
782 fprintf(stderr,
"Error during processing.\n");