515 const char* lang =
nullptr;
516 const char* image =
nullptr;
517 const char* outputbase =
nullptr;
518 const char* datapath =
nullptr;
519 bool list_langs =
false;
520 bool print_parameters =
false;
524 #ifdef DISABLED_LEGACY_ENGINE 537 setMsgSeverity(L_SEVERITY_ERROR);
540 #if defined(HAVE_TIFFIO_H) && defined(_WIN32) 542 TIFFSetErrorHandler(Win32ErrorHandler);
543 TIFFSetWarningHandler(Win32WarningHandler);
544 #endif // HAVE_TIFFIO_H && _WIN32 546 ParseArgs(argc, argv, &lang, &image, &outputbase, &datapath, &dpi,
547 &list_langs, &print_parameters, &vars_vec, &vars_values, &arg_i,
548 &pagesegmode, &enginemode);
550 if (lang ==
nullptr) {
555 if (image ==
nullptr && !list_langs && !print_parameters)
568 api.SetOutputName(outputbase);
570 const
int init_failed = api.Init(datapath, lang, enginemode, &(argv[arg_i]),
571 argc - arg_i, &vars_vec, &vars_values, false);
573 SetVariablesFromCLArgs(&api, argc, argv);
576 PrintLangsList(&api);
581 fprintf(stderr,
"Could not initialize tesseract.\n");
585 if (print_parameters) {
587 fprintf(stdout,
"Tesseract parameters:\n");
588 api.PrintVariables(fout);
593 FixPageSegMode(&api, pagesegmode);
596 char dpi_string[255];
597 snprintf(dpi_string, 254,
"%d", dpi);
598 api.SetVariable(
"user_defined_dpi", dpi_string);
602 int ret_val = EXIT_SUCCESS;
604 Pix* pixs = pixRead(image);
606 fprintf(stderr,
"Leptonica can't process input file: %s\n", image);
621 "Orientation: %d\nWritingDirection: %d\nTextlineOrder: %d\n" 622 "Deskew angle: %.4f\n",
623 orientation,
direction, order, deskew_angle);
625 ret_val = EXIT_FAILURE;
637 bool in_training_mode =
638 (api.GetBoolVariable(
"tessedit_ambigs_training", &b) && b) ||
639 (api.GetBoolVariable(
"tessedit_resegment_from_boxes", &b) && b) ||
640 (api.GetBoolVariable(
"tessedit_make_boxes_from_boxes", &b) && b);
642 #ifdef DISABLED_LEGACY_ENGINE 643 auto cur_psm = api.GetPageSegMode();
644 auto osd_warning = std::string(
"");
646 const char* disabled_osd_msg =
647 "\nERROR: The page segmentation mode 0 (OSD Only) is currently disabled.\n\n";
648 fprintf(stderr,
"%s", disabled_osd_msg);
653 "\nWarning: The page segmentation mode 1 (Auto+OSD) is currently disabled. " 654 "Using PSM 3 (Auto) instead.\n\n";
658 "\nWarning: The page segmentation mode 12 (Sparse text + OSD) is currently disabled. " 659 "Using PSM 11 (Sparse text) instead.\n\n";
661 #endif // def DISABLED_LEGACY_ENGINE 666 if (in_training_mode) {
669 PreloadRenderers(&api, &renderers, pagesegmode, outputbase);
673 if (outputbase !=
nullptr && strcmp(outputbase,
"-") &&
674 strcmp(outputbase,
"stdout")) {
678 if (!renderers.
empty()) {
679 if (banner) PrintBanner();
680 #ifdef DISABLED_LEGACY_ENGINE 681 if (!osd_warning.empty()) {
682 fprintf(stderr,
"%s",osd_warning.c_str());
685 bool succeed = api.ProcessPages(image,
nullptr, 0, renderers[0]);
687 fprintf(stderr,
"Error during processing.\n");
Sparse text with orientation and script det.
struct TessBaseAPI TessBaseAPI
int direction(EDGEPT *point)
#define PERF_COUNT_START(FUNCT_NAME)
DLLSYM void tprintf(const char *format,...)
int push_back(T * object)
Find as much text as possible in no particular order.
Automatic page segmentation, but no OSD, or OCR.
Orientation and script detection only.
void Orientation(tesseract::Orientation *orientation, tesseract::WritingDirection *writing_direction, tesseract::TextlineOrder *textline_order, float *deskew_angle) const
Fully automatic page segmentation, but no OSD.