我想从这种图片中捕捉数字.
我尝试从以下链接进行多尺度匹配.
http://www.pyimagesearch.com/2015/01/26/multi-scale-template-matching-using-python-opencv/
我想知道的只是红色数字.但问题是,openCV识别/匹配模板的红色数字模糊.是否有其他可能的方法来检测黑色背景上的这个红色数字?
我一直在寻找网上图像中数字识别的资源.我发现很多链接提供了很多关于该主题的资源.但不幸的是,它比帮助更令人困惑,我不知道从哪里开始.
我有一个带有5个数字的图像,没有受到干扰(没有验证码或类似的东西).数字在白色背景上是黑色的,用标准字体书写.
我的第一步是分开数字.我目前使用的算法非常简单,它只检查列是否完全是白色,因此是一个空格.然后它修剪每个角色,使其周围没有白色边框.这非常有效.
但是现在我对这个号码的实际识别感到困惑.我不知道猜测正确方法的最佳方法是什么.我不认为直接比较字体是一个好主意,因为如果数字只有一点点差异,那就没有更多的工作了.
任何人都可以给我一个如何做到这一点的暗示吗?
问题无关紧要,但我将用C#或Java实现它.我找到了一些可以完成这项工作的图书馆,但我想自己实施,以便学习一些东西.
这是我通过Tesseract引擎进行数字识别的iOS OCR代码:
Tesseract* tesseract = [[Tesseract alloc] initWithDataPath:@"tessdata" language:@"eng"];
//set the tesseract variables
[tesseract setVariableValue:@"0123456789" forKey:@"tessedit_char_whitelist"];
NSString * temp = @"7";
[tesseract setVariableValue:temp forKey:@"tessedit_pageseg_mode"];
[tesseract setImage:argImage];
[tesseract recognize];
m_convertedText = [[tesseract recognizedText] copy];
Run Code Online (Sandbox Code Playgroud)
使用上面,我得到一些正确的图像.但是有时我会得到5而不是8,6而不是5等等.我的输入图像非常完美 - 二值化后的纯黑色和白色.
我还缺少其他任何Tesseract选项吗?我看到有600多个选项和非常稀疏的文档.
我能找到的最好的是这个网站列出了所有选项,但对于OCR初学者来说还不是很清楚.
如果有人通过使用tesseract的数字OCR达到了100%的准确率,那将非常有帮助.
详细信息:Ubuntu 14.04(LTS),OpenCV 2.4.13,Spyder 2.3.9(Python 2.7),Tensorflow r0.10
我想用Python和Tensorflow(可选的OpenCV)从图像中识别Number .
另外,我想使用具有张量流的MNIST数据训练
像这样(代码被引用到这个页面的视频),
码:
import tensorflow as tf
import random
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
x = tf.placeholder("float", [None, 784])
y = tf.placeholder("float", [None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
learning_rate = 0.01
training_epochs = 25
batch_size = 100
display_step = 1
### modeling ###
activation = tf.nn.softmax(tf.matmul(x, W) + b)
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y * tf.log(activation), reduction_indices=1))
optimizer …
Run Code Online (Sandbox Code Playgroud) 我使用 python 和 keras ocr。我希望 keras 只识别数字,所以在管道中我这样做。
recognizer = keras_ocr.recognition.Recognizer(alphabet="0123456789")
pipeline = keras_ocr.pipeline.Pipeline(recognizer=recognizer)
Run Code Online (Sandbox Code Playgroud)
但它并没有像超立方体白名单那样将字母转换为数字并提高识别质量。
所以这些数字根本不被识别。
使用默认字母表结果更好。但有些数字与字母混淆。然而,将字母更改为数字,如“replace("O", "0")”是一个非常糟糕的主意。
识别功能很简单,复制一下:)
_image = keras_ocr.tools.read(_path)
plt.figure(figsize=(10, 20))
plt.imshow(_image)
prediction = pipeline.recognize([_image])[0]
fig, axs = plt.subplots(1, figsize=(10, 20))
keras_ocr.tools.drawAnnotations(image=_image, predictions=prediction, ax=axs)
plt.show()
Run Code Online (Sandbox Code Playgroud)