Skip to content

Commit

Permalink
Merge pull request #918 from rfschtkt/issue529
Browse files Browse the repository at this point in the history
Issue529
  • Loading branch information
zdenop committed May 13, 2017
2 parents 5c8f88b + b4cf466 commit ffb1ec3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,33 +440,33 @@ int main(int argc, char** argv) {
argc - arg_i, &vars_vec, &vars_values, false);
if (init_failed) {
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
return EXIT_FAILURE;
}

SetVariablesFromCLArgs(&api, argc, argv);

if (list_langs) {
PrintLangsList(&api);
exit(0);
return EXIT_SUCCESS;
}

if (print_parameters) {
FILE* fout = stdout;
fprintf(stdout, "Tesseract parameters:\n");
api.PrintVariables(fout);
api.End();
exit(0);
return EXIT_SUCCESS;
}

FixPageSegMode(&api, pagesegmode);

if (pagesegmode == tesseract::PSM_AUTO_ONLY) {
int ret_val = 0;
int ret_val = EXIT_SUCCESS;

Pix* pixs = pixRead(image);
if (!pixs) {
fprintf(stderr, "Cannot open input file: %s\n", image);
exit(2);
return 2;
}

api.SetImage(pixs);
Expand All @@ -484,13 +484,13 @@ int main(int argc, char** argv) {
"Deskew angle: %.4f\n",
orientation, direction, order, deskew_angle);
} else {
ret_val = 1;
ret_val = EXIT_FAILURE;
}

delete it;

pixDestroy(&pixs);
exit(ret_val);
return ret_val;
}

// set in_training_mode to true when using one of these configs:
Expand All @@ -515,10 +515,11 @@ int main(int argc, char** argv) {
bool succeed = api.ProcessPages(image, NULL, 0, renderers[0]);
if (!succeed) {
fprintf(stderr, "Error during processing.\n");
exit(1);
return EXIT_FAILURE;
}
}

PERF_COUNT_END
return 0; // Normal exit

return EXIT_SUCCESS;
}
4 changes: 2 additions & 2 deletions dict/dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,12 @@ void Dict::Load(const STRING &lang, TessdataManager *data_file) {
if (load_bigram_dawg) {
bigram_dawg_ = dawg_cache_->GetSquishedDawg(lang, TESSDATA_BIGRAM_DAWG,
dawg_debug_level, data_file);
if (bigram_dawg_) dawgs_ += bigram_dawg_;
}
if (load_freq_dawg) {
freq_dawg_ = dawg_cache_->GetSquishedDawg(lang, TESSDATA_FREQ_DAWG,
dawg_debug_level, data_file);
if (freq_dawg_) { dawgs_ += freq_dawg_; }
if (freq_dawg_) dawgs_ += freq_dawg_;
}
if (load_unambig_dawg) {
unambig_dawg_ = dawg_cache_->GetSquishedDawg(lang, TESSDATA_UNAMBIG_DAWG,
Expand Down Expand Up @@ -351,7 +352,6 @@ void Dict::End() {
delete dawgs_[i];
}
}
dawg_cache_->FreeDawg(bigram_dawg_);
if (dawg_cache_is_ours_) {
delete dawg_cache_;
dawg_cache_ = NULL;
Expand Down

0 comments on commit ffb1ec3

Please sign in to comment.