Commit 7189c698 authored by Jerome Flesch's avatar Jerome Flesch

Revert "Merge pull request #100 from ddddavidmartin/update_deprecated_psm_option_string":

- Breaks tests (module import loop)
- Breaks style checks

This reverts commit 2c416705, reversing
changes made to 31fb5f14.
parent 35ad4001
......@@ -14,7 +14,6 @@ except ImportError:
import xml.dom.minidom
import logging
from .tesseract import psm_parameter
from .util import to_unicode
logger = logging.getLogger(__name__)
......@@ -306,7 +305,7 @@ class TextBuilder(BaseBuilder):
def __init__(self, tesseract_layout=3, cuneiform_dotmatrix=False,
cuneiform_fax=False, cuneiform_singlecolumn=False):
file_ext = ["txt"]
tess_flags = [psm_parameter(), str(tesseract_layout)]
tess_flags = ["-psm", str(tesseract_layout)]
cun_args = ["-f", "text"]
# Add custom cuneiform parameters if needed
for par, arg in [(cuneiform_dotmatrix, "--dotmatrix"),
......@@ -563,7 +562,7 @@ class WordBoxBuilder(BaseBuilder):
def __init__(self, tesseract_layout=1):
file_ext = ["html", "hocr"]
tess_flags = [psm_parameter(), str(tesseract_layout)]
tess_flags = ["-psm", str(tesseract_layout)]
tess_conf = ["hocr"]
cun_args = ["-f", "hocr"]
super(WordBoxBuilder, self).__init__(file_ext, tess_flags, tess_conf,
......@@ -639,7 +638,7 @@ class LineBoxBuilder(BaseBuilder):
def __init__(self, tesseract_layout=1):
file_ext = ["html", "hocr"]
tess_flags = [psm_parameter(), str(tesseract_layout)]
tess_flags = ["-psm", str(tesseract_layout)]
tess_conf = ["hocr"]
cun_args = ["-f", "hocr"]
super(LineBoxBuilder, self).__init__(file_ext, tess_flags, tess_conf,
......
......@@ -161,15 +161,6 @@ def can_detect_orientation():
)
def psm_parameter():
"""Return the psm option string depending on the Tesseract version."""
version = get_version()
if version[0] <= 3:
return "-psm"
return "--psm"
def detect_orientation(image, lang=None):
"""
Arguments:
......@@ -187,7 +178,7 @@ def detect_orientation(image, lang=None):
"""
_set_environment()
with temp_dir() as tmpdir:
command = [TESSERACT_CMD, "input.bmp", 'stdout', psm_parameter(), "0"]
command = [TESSERACT_CMD, "input.bmp", 'stdout', "-psm", "0"]
version = get_version()
if version[0] >= 4:
# XXX: temporary fix to remove once Tesseract 4 is stable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment