Skip to content

Commit

Permalink
Add a command-line option (--print-parameters) to dump the parameters…
Browse files Browse the repository at this point in the history
… to stdout

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@814 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
zdenop@gmail.com committed Dec 23, 2012
1 parent 4812fac commit 37fb755
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 0 additions & 2 deletions api/baseapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ class TESS_API TessBaseAPI {
* Or SetVariable("classify_bln_numeric_mode", "1"); to set numeric-only mode.
* SetVariable may be used before Init, but settings will revert to
* defaults on End().
* TODO(rays) Add a command-line option to dump the parameters to stdout
* and add a pointer to it in the FAQ
*
* Note: Must be called after Init(). Only works for non-init variables
* (init variables should be passed to Init()).
Expand Down
14 changes: 14 additions & 0 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ int main(int argc, char **argv) {
const char* output = NULL;
bool noocr = false;
bool list_langs = false;
bool print_parameters = false;

tesseract::PageSegMode pagesegmode = tesseract::PSM_AUTO;
int arg = 1;
Expand All @@ -86,6 +87,9 @@ int main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-psm") == 0 && arg + 1 < argc) {
pagesegmode = static_cast<tesseract::PageSegMode>(atoi(argv[arg + 1]));
++arg;
} else if (strcmp(argv[arg], "--print-parameters") == 0) {
noocr = true;
print_parameters = true;
} else if (image == NULL) {
image = argv[arg];
} else if (output == NULL) {
Expand Down Expand Up @@ -121,6 +125,8 @@ int main(int argc, char **argv) {
fprintf(stderr, _(" -v --version: version info\n"));
fprintf(stderr, _(" --list-langs: list available languages for tesseract "
"engine\n"));
fprintf(stderr, _(" --print-parameters: print tesseract parameters to the "
"stdout\n"));
exit(1);
}

Expand Down Expand Up @@ -150,6 +156,14 @@ int main(int argc, char **argv) {
exit(0);
}

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

// We have 2 possible sources of pagesegmode: a config file and
// the command line. For backwards compatability reasons, the
// default in tesseract is tesseract::PSM_SINGLE_BLOCK, but the
Expand Down

0 comments on commit 37fb755

Please sign in to comment.