有没有办法获得 Pytesseract 生成的 OCR 输出的 信任率? 我所说的信任率是指 OCR 输出的正确率。
例子:
text = pytesseract.image_to_string(editedImage)
对于这个文本字符串,如果可能的话,我还想显示信任度。
编辑:我尝试了 image_to_data 但出现错误
print(pytesseract.image_to_data(Image.open('test.png')))
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 1536, in __call__
return self.func(*args)
File "/home/caner/Desktop/Met/OCR-METv3/venv/tkgui.py", line 192, in convert
print(pytesseract.image_to_data(Image.open('test.png')))
File "/home/caner/Desktop/Met/OCR-METv3/venv/lib/python3.4/site-packages/pytesseract/pytesseract.py", line 232, in image_to_data
return run_and_get_output(image, 'tsv', lang, config, nice)
File "/home/caner/Desktop/Met/OCR-METv3/venv/lib/python3.4/site-packages/pytesseract/pytesseract.py", line 142, in run_and_get_output
with open(filename, 'rb') as output_file:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tess_2mxczh8n_out.tsv'
请您参考如下方法:
我猜你指的是 confidence 和 trust rate。 在 pytesseract 模块的 repo 协议(protocol)中有一些关于此的信息 here .
Functions
- image_to_string Returns the result of a Tesseract OCR run on the image to string
- image_to_boxes Returns result containing recognized characters and their box boundaries
- image_to_data Returns result containing box boundaries, confidences, and other information. Requires Tesseract 3.05+. For more information, please check the Tesseract TSV documentation
我认为您正在寻找的是 image_to_data 函数。
