【发布时间】:2018-08-16 23:11:09
【问题描述】:
我遵循了 OCR 包,它适用于默认测试图像。但是一旦我改变了图像,我就会得到一个错误。
https://github.com/Breta01/handwriting-ocr/blob/master/OCR.ipynb
如果我禁用此行,则会执行代码,但由于显而易见的原因无法正确读取文本。
crop = page.detection(image)
详情如下:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-66-869a5b4b76fb> in <module>()
1 # Crop image and get bounding boxes
----> 2 crop = page.detection(image)
3 implt(image)
4 bBoxes = words.detection(image)
~/SageMaker/handwriting-ocr/ocr/page.py in detection(image)
17 np.ones((5, 11)))
18 # Countours
---> 19 pageContour = findPageContours(closedEdges, resize(image))
20 # Recalculate to original scale
21 pageContour = pageContour.dot(ratio(image))
~/SageMaker/handwriting-ocr/ocr/page.py in findPageContours(edges, img)
94
95 # Sort corners and offset them
---> 96 pageContour = fourCornersSort(pageContour[:, 0])
97 return contourOffset(pageContour, (-5, -5))
98
~/SageMaker/handwriting-ocr/ocr/page.py in fourCornersSort(pts)
47 def fourCornersSort(pts):
48 """ Sort corners: top-left, bot-left, bot-right, top-right"""
---> 49 diff = np.diff(pts, axis=1)
50 summ = pts.sum(axis=1)
51 return np.array([pts[np.argmin(summ)],
~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/numpy/lib/function_base.py in diff(a, n, axis)
1922 slice1 = [slice(None)]*nd
1923 slice2 = [slice(None)]*nd
-> 1924 slice1[axis] = slice(1, None)
1925 slice2[axis] = slice(None, -1)
1926 slice1 = tuple(slice1)
IndexError: list assignment index out of range
我希望这能正常工作,因为我要导入手写文档,而大多数(非 ML)软件都无法正确读取它们。
更新:
假设一家公司有 100 名员工将提交手写文件。这是否意味着我需要收集所有 100 个人的笔迹样本来训练模型?
更新 1:
也许我没有正确解释我的问题。我有一张图片:
https://s3.amazonaws.com/todel162/harshad_college_card.jpg
tessaract OCR 无法正确读取。如在此文本文件中所见 - 缺少姓名、标准和出生日期(这是最重要的)
https://s3.amazonaws.com/todel162/college_card_reading.txt
是否有任何软件包(带有或不带有 ML)可以从单个文档中读取打印和手写的文本,这些文档可能会以不同的分辨率/尺寸(由最终用户)扫描
【问题讨论】:
-
您的问题是专门读取这种格式的身份证图像吗?还是需要阅读任意文件?
-
是的。身份证图像是第一要务。如果我能做到这一点,我将管理其他格式,如“标记表”。文档格式正确,本质上不是任意的。我尝试了 google vision API,但正在寻找免费和开源的选项。
标签: opencv machine-learning ocr tesseract