我的软件需要读取一个固定长度的手写数字,例如596276。
虽然我可以使用像特塞尔这样的通用库,但我相信还有一些更聪明的东西。Tesseract可能会将1或7中的某些曲解为I或l,而只有数字的软件则不会。
知道只有数字(美式-英语的书写方式),该算法可以专注于10个潜在的匹配,而不是数以百计的符号。
有过OCRing手写体数字字段的经验吗?
你用什么开源库/软件获得了最好的结果?
必须是开放源代码并脱机工作。最好是Java,任何其他接受的技术(.NET、JavaScript、C等),但必须能够在Linux/Mac/Windows/Android上运行。
发布于 2016-01-07 04:24:48
设计用于打印(而不是手写)文本,因此即使是数字也可能会影响准确性,但无论如何:
来自常见问题 of Tesseract:
我怎么才能认出数字?在2.03和更高版本中:使用TessBaseAPI::SetVariable("tessedit_char_whitelist",“0123456789”;在调用Init函数或将其放入名为
tessdata/configs/digits:tessedit_char_whitelist 0123456789的文本文件中之前,您的命令行变为: tesseract image.tif outputbase no批处理数字警告:在旧的配置变量和新的配置变量合并之前,必须使用nobatch参数。
发布于 2016-01-07 07:41:24
您可以使用Python和OpenCV来完成这一任务,并对您的识别引擎进行一些培训。作为默认安装的一部分,甚至还有一个示例和一些初始培训示例。
来自教程
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('digits.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# Now we split the image to 5000 cells, each 20x20 size
cells = [np.hsplit(row,100) for row in np.vsplit(gray,50)]
# Make it into a Numpy array. It size will be (50,100,20,20)
x = np.array(cells)
# Now we prepare train_data and test_data.
train = x[:,:50].reshape(-1,400).astype(np.float32) # Size = (2500,400)
test = x[:,50:100].reshape(-1,400).astype(np.float32) # Size = (2500,400)
# Create labels for train and test data
k = np.arange(10)
train_labels = np.repeat(k,250)[:,np.newaxis]
test_labels = train_labels.copy()
# Initiate kNN, train the data, then test it with test data for k=1
knn = cv2.KNearest()
knn.train(train,train_labels)
ret,result,neighbours,dist = knn.find_nearest(test,k=5)
# Now we check the accuracy of classification
# For that, compare the result with test_labels and check which are wrong
matches = result==test_labels
correct = np.count_nonzero(matches)
accuracy = correct*100.0/result.size
print accuracy一旦经过训练,您将保存您的识别数据供以后使用。
好处:
https://softwarerecs.stackexchange.com/questions/27834
复制相似问题