Don't hide OCR errors by doing a fallback try without language option. gh-issue #211

This commit is contained in:
Roberto Rosario
2015-07-18 03:25:03 -04:00
parent 719d83d652
commit ba7cb433d4

View File

@@ -26,11 +26,8 @@ class Tesseract(OCRBackendBase):
# If tesseract gives an error with a language parameter
# re-run it with no language parameter
except Exception as exception:
logger.error('Exception calling pytesseract with language option: %s; %s', self.language, exception)
try:
result = pytesseract.image_to_string(image=image)
except Exception as exception:
logger.debug('Exception calling pytesseract without a language option; %s', exception)
raise OCRError
error_message = 'Exception calling pytesseract with language option: {}; {}'.format(self.language, exception)
logger.error(error_message)
raise OCRError(error_message)
return result