我不能在Ubuntu上的映像上运行pytesseract中的OSD模式。在windows上,此命令的工作方式类似于魅力:
pytesseract.image_to_osd(image)
但是在对接图像中,它会导致以下错误。我想要实现的是使用OSD读取旋转信息。
File "/usr/local/lib/python3.9/site-packages/pytesseract/pytesseract.py", line 263, in run_tesseract
raise TesseractError(proc.returncode, get_errors(error_string))pytesseract.pytesseract.TesseractError: (1, 'Tesseract Open Source OCR Engine v5.0.0-alpha-20210401 with Leptonica UZN file /tmp/tess__cujlspf loaded. Estimating resolution as 169 UZN file /tmp/tess__cujlspf loaded. Warning. Invalid resolution 0 dpi. Using 70 instead. Too few characters. Skipping this page Error during processing.')
Tesseract的安装是正确的,因为所有其他方法(如image_to_string )都在正常工作。令人惊讶的是,当我从终端直接呼叫OSD时,它可以工作。
tesseract /images/1.jpg output --psm 0
# cat output.osd
Page number: 0
Orientation in degrees: 0
Rotate: 0
Orientation confidence: 5.69
Script: Cyrillic
Script confidence: 0.10
在Pytesseract中有什么bug或其他解决方法吗?旋转信息不包括在任何其他的Tesseract方法,只有在这个OSD。非常感谢
发布于 2021-10-05 08:08:28
通过将config参数添加到方法调用中,我找到了解决方案:
pytesseract.image_to_osd(file_name,config='--psm 0 -c min_characters_to_try=5')
这解决了误差,我可以得到角度数据。
https://stackoverflow.com/questions/67018785
复制相似问题