我正在做很多患者摄入量调查表。这是问卷的扫描示例。我需要处理它们并存储到数据库中,但是在检测这些手写标记时遇到了问题:
患者摄入量问卷
问卷中有不同类型的标记。一些复选框被涂成黑色。一些复选框有勾号或十字标记。这些标记确实意味着选中了复选框。我需要使用 opencv2 来识别选中了哪些框。
我已经尝试过光学字符识别,但结果并没有什么帮助。标记的形状太多,因此 OCR 将它们识别为不同的字符。我需要弄清楚在问卷中选中了哪些框。cv2 可以解决这个问题,但我不知道。
# Expected input: An image of Questionnaire
# Expected output:
Have you seen other health care providers for your problems of dizziness
and/or imbalance? [selected] Yes [unselected] No
Have you been through a program of Vestibular and Balance Rehabilitation
Therapy? [selected] Yes [unselected] No
=============================
[unselected] vertigo
[unselected] falling
...
[selected] Drunk-like
=============================
[selected] Vertigo
[selected] Falling
[selected] Fatigue
[selected] Wooziness
[selected] Spinning
[unselected] Disconnected
我之前使用 Python tesseract OCR 包的尝试:
from PIL import Image
import pytesseract
path ="page1.jpg"
img = Image.open(path)
text = pytesseract.image_to_string(img, lang='eng', config='-c preserve_interword_spaces=1 --psm 6')
print text
O Vertigo O Falling O Fatigue W Vertigo YA Falling y[ Fatigue
[ Wooziness O Spinning O Disconnected A \Wooziness Q Spinning [ Disconnected
O Imbalance B Drunk-like O Swirling O Imbalance O Drunk-like @ Swirling ;
O Faint [ Rocking O Can’tfocus M Faint 4 Rocking O Can’t focus
O Lightheaded O Swaying -~ . -0 Unsteady O Lightheaded O Swaying N Unsteady
O “onaboat” O Swimming sensation Weonaboat” @ Swimming sensation
O Other: 0 Other:
我的想法是:如果 OCR 将矩形复选框识别为字符“O”或数字“0”,则应取消选中该复选框。否则应该选择它。基于该规则,我可以根据 OCR 结果检测手写标记。我将测试几个样本并查看精度,但我不确定这是否可行。如果是这样,我会在稍后回复这篇文章。