fix: Ensure that TesseractOcrModel does not crash in case OSD is not installed (#1866)
fix: Ensure that TesseractOcrModel does not crash if tesseract OSD is not installed Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
This commit is contained in:
parent
bb99be6c24
commit
ae39a9411a
@ -144,7 +144,10 @@ class TesseractOcrModel(BaseOcrModel):
|
|||||||
|
|
||||||
local_reader = self.reader
|
local_reader = self.reader
|
||||||
self.osd_reader.SetImage(high_res_image)
|
self.osd_reader.SetImage(high_res_image)
|
||||||
|
|
||||||
|
doc_orientation = 0
|
||||||
osd = self.osd_reader.DetectOrientationScript()
|
osd = self.osd_reader.DetectOrientationScript()
|
||||||
|
|
||||||
# No text, or Orientation and Script detection failure
|
# No text, or Orientation and Script detection failure
|
||||||
if osd is None:
|
if osd is None:
|
||||||
_log.error(
|
_log.error(
|
||||||
@ -158,11 +161,14 @@ class TesseractOcrModel(BaseOcrModel):
|
|||||||
# to OCR in the hope OCR will succeed while OSD failed
|
# to OCR in the hope OCR will succeed while OSD failed
|
||||||
if self._is_auto:
|
if self._is_auto:
|
||||||
continue
|
continue
|
||||||
doc_orientation = parse_tesseract_orientation(osd["orient_deg"])
|
else:
|
||||||
if doc_orientation != 0:
|
doc_orientation = parse_tesseract_orientation(
|
||||||
high_res_image = high_res_image.rotate(
|
osd["orient_deg"]
|
||||||
-doc_orientation, expand=True
|
|
||||||
)
|
)
|
||||||
|
if doc_orientation != 0:
|
||||||
|
high_res_image = high_res_image.rotate(
|
||||||
|
-doc_orientation, expand=True
|
||||||
|
)
|
||||||
if self._is_auto:
|
if self._is_auto:
|
||||||
script = osd["script_name"]
|
script = osd["script_name"]
|
||||||
script = map_tesseract_script(script)
|
script = map_tesseract_script(script)
|
||||||
|
Loading…
Reference in New Issue
Block a user