【发布时间】:2020-12-11 09:05:31
【问题描述】:
我需要计算 OCR 字符准确度
样品地面值:
Non sinking ship is friendship
ocr值输入示例:
non singing ship is finedship
关注的领域是:
- 遗漏字符
- 额外字符
- 错位的字符
字符准确度由实际字符数及其位置除以实际字符总数来定义。
我需要一个 python 脚本来找到这个准确性。我的初始实现如下:
ground_value = "Non sinking ship is friendship"
ocr_value = "non singing ship is finedship"
ground_value_characters = (re.sub('\s+', '',
ground_value)).strip() # remove all spaces from the gr value string
ocr_value_characters = (re.sub('\s+', '',
ocr_value)).strip() # remove all the spaces from the ocr string
total_characters = float(len(
ground_value_characters))
def find_matching_characters(ground, ocr):
total = 0
for char in ground:
if char in ocr:
total = total + 1
ocr = ocr.replace(char, '', 1)
return total
found_characters = find_matching_characters(ground_value_characters,
ocr_value_characters)
accuracy = found_characters/total_characters
我无法得到我所希望的。任何帮助将不胜感激。
【问题讨论】:
-
这与浮动精度无关。
标签: python python-3.x computer-vision ocr