Skip to content

Commit 26bfd2b

Browse files
committed
Allow orientation detection with any traineddata
While orientation and script detection (OSD) normally requires osd.traineddata to detect both, it must also be possible to do only orientation detection with eng.traineddata or any other traineddata. Enforce osd.traineddata only if there was no `-l` command line option. Commit 27ce472 was too restrictive. Signed-off-by: Stefan Weil <[email protected]>
1 parent 6b9f1f1 commit 26bfd2b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/api/tesseractmain.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,15 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
367367
*arg_i = i;
368368

369369
if (*pagesegmode == tesseract::PSM_OSD_ONLY) {
370-
// That mode requires osd.traineddata, no other language or script files.
370+
// OSD = orientation and script detection.
371371
if (*lang != nullptr && strcmp(*lang, "osd")) {
372-
fprintf(stderr, "Warning, ignoring -l %s for --psm 0\n", *lang);
372+
// If the user explicitly specifies a language (other than osd)
373+
// or a script, only orientation can be detected.
374+
fprintf(stderr, "Warning, detects only orientation with -l %s\n", *lang);
375+
} else {
376+
// That mode requires osd.traineddata to detect orientation and script.
377+
*lang = "osd";
373378
}
374-
*lang = "osd";
375379
}
376380

377381
if (*outputbase == nullptr && noocr == false) {

0 commit comments

Comments
 (0)