Add different timeout control for non-OCR

This is mainly to permit the use of --tesseract-timeout 0 as a way of
disabling OCR but still allowing deskew and orientation detection to work.

The better solution will be introducing an explicit argument to
"don't ocr my pdf", but that will take more rework.
This commit is contained in:
James R. Barlow
2023-04-13 22:58:12 -07:00
parent 5502fb8d9f
commit b432770cfc
+17 -4
View File
@@ -69,8 +69,21 @@ def add_options(parser):
default=180.0,
type=numeric(float, 0),
metavar='SECONDS',
help='Give up on OCR after the timeout, but copy the preprocessed page '
'into the final output',
help=(
"Give up on OCR after the timeout, but copy the preprocessed page "
"into the final output."
),
)
tess.add_argument(
'--tesseract-non-ocr-timeout',
default=180.0,
type=numeric(float, 0),
metavar='SECONDS',
help=(
"Give up on non-OCR operations such as deskewing and orientation "
"after timeout. This is a separate timeout from --tesseract-timeout "
"because these operations are not as expensive as OCR."
),
)
tess.add_argument(
'--user-words',
@@ -156,7 +169,7 @@ class TesseractOcrEngine(OcrEngine):
return tesseract.get_orientation(
input_file,
engine_mode=options.tesseract_oem,
timeout=options.tesseract_timeout,
timeout=options.tesseract_non_ocr_timeout,
)
@staticmethod
@@ -165,7 +178,7 @@ class TesseractOcrEngine(OcrEngine):
input_file,
languages=options.languages,
engine_mode=options.tesseract_oem,
timeout=options.tesseract_timeout,
timeout=options.tesseract_non_ocr_timeout,
)
@staticmethod