Я работаю над AWS - Лямбда (Python).
Я работаю над уже существующим кодом, который использует пакет tesseract
. В моей главной функции есть функция, которая вызывает это:
def lambda_ocr(ze_path, step):
if step == 1:
ocr_options = "--oem 1 -l eng --psm 6"
elif step == 2:
ocr_options = "--oem 0 -l eng --psm 6"
elif step == 3:
ocr_options = "--oem 1 -l fra --psm 3"
elif step == 4 :
ocr_options = "--oem 0 -l fra --psm 11"
else:
print("WARNING invalid step given for ocr. default option --oem 1 -l fra --psm 3.")
ocr_options = "--oem 1 -l fra --psm 3"
res = ocr(ze_path, config=ocr_options)
def ocr(img_path, config="--oem 1 -l fra --psm 3"):
""" This function is called by get_text_OCR_Parallel
we can modify the tesseract config here
"""
raw_text = pytesseract.image_to_string(img_path, config=config)
return raw_text
def image_to_string(image,
lang=None,
config='',
nice=0,
output_type=Output.STRING):
'''
Returns the result of a Tesseract OCR run on the provided image to string
'''
args = [image, 'txt', lang, config, nice]
return {
Output.BYTES: lambda: run_and_get_output(*(args + [True])),
Output.DICT: lambda: {'text': run_and_get_output(*args)},
Output.STRING: lambda: run_and_get_output(*args),
}[output_type]()
Когда я вызываю функцию lambda_ocr
с шагом = 1, все работает нормально. Но когда шаг = 2, 3 или 4, он выдает ошибку.
Я не знаю много о пакете tesseract
, но согласно this я должен установить недостающие пакеты.
Что я не понимаю, так это как работает, когда шаг = 1, если пакет плохо установлен? Разве это не должно выдать ошибку тоже?
Любая помощь приветствуется. Спасибо