Skip to content

Commit 92d981b

Browse files
committed
Change tesseract parameter -psm to --psm
For compatibility reasons the old variant is still supported. Signed-off-by: Stefan Weil <[email protected]>
1 parent d2f9264 commit 92d981b

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ You can either [Install Tesseract via pre-built binary package](https://github.c
6363

6464
Basic command line usage:
6565

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

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

api/tesseractmain.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void PrintHelpMessage(const char* program) {
142142
" -l LANG[+LANG] Specify language(s) used for OCR.\n"
143143
" -c VAR=VALUE Set value for config variables.\n"
144144
" Multiple -c arguments are allowed.\n"
145-
" -psm NUM Specify page segmentation mode.\n"
145+
" --psm NUM Specify page segmentation mode.\n"
146146
" --oem NUM Specify OCR Engine mode.\n"
147147
"NOTE: These options must occur before any configfile.\n";
148148

@@ -275,6 +275,11 @@ void ParseArgs(const int argc, char** argv, const char** lang,
275275
noocr = true;
276276
*list_langs = true;
277277
} else if (strcmp(argv[i], "-psm") == 0 && i + 1 < argc) {
278+
// The parameter -psm is deprecated and was replaced by --psm.
279+
// It is still supported for compatibility reasons.
280+
*pagesegmode = static_cast<tesseract::PageSegMode>(atoi(argv[i + 1]));
281+
++i;
282+
} else if (strcmp(argv[i], "--psm") == 0 && i + 1 < argc) {
278283
*pagesegmode = static_cast<tesseract::PageSegMode>(atoi(argv[i + 1]));
279284
++i;
280285
} else if (strcmp(argv[i], "--oem") == 0 && i + 1 < argc) {

doc/tesseract.1

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Set value for control parameter\&. Multiple \-c arguments are allowed\&.
8484
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)
8585
.RE
8686
.PP
87-
\fI\-psm N\fR
87+
\fI\--psm N\fR
8888
.RS 4
8989
Set Tesseract to only run a subset of layout analysis and assume a certain form of image\&. The options for
9090
\fBN\fR
@@ -139,7 +139,7 @@ pdf \- Output in pdf instead of a text file\&.
139139
.RE
140140
.RE
141141
.sp
142-
\fBNota Bene:\fR The options \fI\-l lang\fR and \fI\-psm N\fR must occur before any \fIconfigfile\fR\&.
142+
\fBNota Bene:\fR The options \fI\-l lang\fR and \fI\--psm N\fR must occur before any \fIconfigfile\fR\&.
143143
.SH "SINGLE OPTIONS"
144144
.PP
145145
\fI\-v\fR

doc/tesseract.1.asc

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ OPTIONS
5454
Multiple languages may be specified, separated by plus characters.
5555
Tesseract uses 3-character ISO 639-2 language codes. (See LANGUAGES)
5656

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

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

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

8484

doc/tesseract.1.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ <h2 id="_options">OPTIONS</h2>
847847
</p>
848848
</dd>
849849
<dt class="hdlist1">
850-
<em>-psm N</em>
850+
<em>--psm N</em>
851851
</dt>
852852
<dd>
853853
<p>
@@ -893,7 +893,7 @@ <h2 id="_options">OPTIONS</h2>
893893
</ul></div>
894894
</dd>
895895
</dl></div>
896-
<div class="paragraph"><p><strong>Nota Bene:</strong> The options <em>-l lang</em> and <em>-psm N</em> must occur
896+
<div class="paragraph"><p><strong>Nota Bene:</strong> The options <em>-l lang</em> and <em>--psm N</em> must occur
897897
before any <em>configfile</em>.</p></div>
898898
</div>
899899
</div>

doc/tesseract.1.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ at Google since then.</simpara>
130130
</varlistentry>
131131
<varlistentry>
132132
<term>
133-
<emphasis>-psm N</emphasis>
133+
<emphasis>--psm N</emphasis>
134134
</term>
135135
<listitem>
136136
<simpara>
@@ -176,7 +176,7 @@ pdf - Output in pdf instead of a text file.
176176
</listitem>
177177
</varlistentry>
178178
</variablelist>
179-
<simpara><emphasis role="strong">Nota Bene:</emphasis> The options <emphasis>-l lang</emphasis> and <emphasis>-psm N</emphasis> must occur
179+
<simpara><emphasis role="strong">Nota Bene:</emphasis> The options <emphasis>-l lang</emphasis> and <emphasis>--psm N</emphasis> must occur
180180
before any <emphasis>configfile</emphasis>.</simpara>
181181
</refsect1>
182182
<refsect1 id="_single_options">

testing/runtestset.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ do
6464
srcdir="$imdir"
6565
fi
6666
# echo "$srcdir/$page.tif"
67-
$tess $srcdir/$page.tif $resdir/$page -psm 6 $config 2>&1 |grep -v "OCR Engine"
67+
$tess $srcdir/$page.tif $resdir/$page --psm 6 $config 2>&1 |grep -v "OCR Engine"
6868
if [ -r times.txt ]
6969
then
7070
read t <times.txt

0 commit comments

Comments
 (0)