Skip to content

Commit

Permalink
Change tesseract parameter -psm to --psm
Browse files Browse the repository at this point in the history
For compatibility reasons the old variant is still supported.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Nov 30, 2016
1 parent d2f9264 commit 92d981b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -63,7 +63,7 @@ You can either [Install Tesseract via pre-built binary package](https://github.c

Basic command line usage:

tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfiles...]
tesseract imagename outputbase [-l lang] [--psm pagesegmode] [configfiles...]

For more information about the various command line options use `tesseract --help` or `man tesseract`.

Expand Down
7 changes: 6 additions & 1 deletion api/tesseractmain.cpp
Expand Up @@ -142,7 +142,7 @@ void PrintHelpMessage(const char* program) {
" -l LANG[+LANG] Specify language(s) used for OCR.\n"
" -c VAR=VALUE Set value for config variables.\n"
" Multiple -c arguments are allowed.\n"
" -psm NUM Specify page segmentation mode.\n"
" --psm NUM Specify page segmentation mode.\n"
" --oem NUM Specify OCR Engine mode.\n"
"NOTE: These options must occur before any configfile.\n";

Expand Down Expand Up @@ -275,6 +275,11 @@ void ParseArgs(const int argc, char** argv, const char** lang,
noocr = true;
*list_langs = true;
} else if (strcmp(argv[i], "-psm") == 0 && i + 1 < argc) {
// The parameter -psm is deprecated and was replaced by --psm.
// It is still supported for compatibility reasons.
*pagesegmode = static_cast<tesseract::PageSegMode>(atoi(argv[i + 1]));
++i;
} else if (strcmp(argv[i], "--psm") == 0 && i + 1 < argc) {
*pagesegmode = static_cast<tesseract::PageSegMode>(atoi(argv[i + 1]));
++i;
} else if (strcmp(argv[i], "--oem") == 0 && i + 1 < argc) {
Expand Down
4 changes: 2 additions & 2 deletions doc/tesseract.1
Expand Up @@ -84,7 +84,7 @@ Set value for control parameter\&. Multiple \-c arguments are allowed\&.
The language to use\&. If none is specified, English is assumed\&. Multiple languages may be specified, separated by plus characters\&. Tesseract uses 3\-character ISO 639\-2 language codes\&. (See LANGUAGES)
.RE
.PP
\fI\-psm N\fR
\fI\--psm N\fR
.RS 4
Set Tesseract to only run a subset of layout analysis and assume a certain form of image\&. The options for
\fBN\fR
Expand Down Expand Up @@ -139,7 +139,7 @@ pdf \- Output in pdf instead of a text file\&.
.RE
.RE
.sp
\fBNota Bene:\fR The options \fI\-l lang\fR and \fI\-psm N\fR must occur before any \fIconfigfile\fR\&.
\fBNota Bene:\fR The options \fI\-l lang\fR and \fI\--psm N\fR must occur before any \fIconfigfile\fR\&.
.SH "SINGLE OPTIONS"
.PP
\fI\-v\fR
Expand Down
4 changes: 2 additions & 2 deletions doc/tesseract.1.asc
Expand Up @@ -54,7 +54,7 @@ OPTIONS
Multiple languages may be specified, separated by plus characters.
Tesseract uses 3-character ISO 639-2 language codes. (See LANGUAGES)

'-psm N'::
'--psm N'::
Set Tesseract to only run a subset of layout analysis and assume
a certain form of image. The options for *N* are:

Expand All @@ -78,7 +78,7 @@ OPTIONS
* hocr - Output in hOCR format instead of as a text file.
* pdf - Output in pdf instead of a text file.

*Nota Bene:* The options '-l lang' and '-psm N' must occur
*Nota Bene:* The options '-l lang' and '--psm N' must occur
before any 'configfile'.


Expand Down
4 changes: 2 additions & 2 deletions doc/tesseract.1.html
Expand Up @@ -847,7 +847,7 @@ <h2 id="_options">OPTIONS</h2>
</p>
</dd>
<dt class="hdlist1">
<em>-psm N</em>
<em>--psm N</em>
</dt>
<dd>
<p>
Expand Down Expand Up @@ -893,7 +893,7 @@ <h2 id="_options">OPTIONS</h2>
</ul></div>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Nota Bene:</strong> The options <em>-l lang</em> and <em>-psm N</em> must occur
<div class="paragraph"><p><strong>Nota Bene:</strong> The options <em>-l lang</em> and <em>--psm N</em> must occur
before any <em>configfile</em>.</p></div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions doc/tesseract.1.xml
Expand Up @@ -130,7 +130,7 @@ at Google since then.</simpara>
</varlistentry>
<varlistentry>
<term>
<emphasis>-psm N</emphasis>
<emphasis>--psm N</emphasis>
</term>
<listitem>
<simpara>
Expand Down Expand Up @@ -176,7 +176,7 @@ pdf - Output in pdf instead of a text file.
</listitem>
</varlistentry>
</variablelist>
<simpara><emphasis role="strong">Nota Bene:</emphasis> The options <emphasis>-l lang</emphasis> and <emphasis>-psm N</emphasis> must occur
<simpara><emphasis role="strong">Nota Bene:</emphasis> The options <emphasis>-l lang</emphasis> and <emphasis>--psm N</emphasis> must occur
before any <emphasis>configfile</emphasis>.</simpara>
</refsect1>
<refsect1 id="_single_options">
Expand Down
2 changes: 1 addition & 1 deletion testing/runtestset.sh
Expand Up @@ -64,7 +64,7 @@ do
srcdir="$imdir"
fi
# echo "$srcdir/$page.tif"
$tess $srcdir/$page.tif $resdir/$page -psm 6 $config 2>&1 |grep -v "OCR Engine"
$tess $srcdir/$page.tif $resdir/$page --psm 6 $config 2>&1 |grep -v "OCR Engine"
if [ -r times.txt ]
then
read t <times.txt
Expand Down

0 comments on commit 92d981b

Please sign in to comment.