Mik*_*ate 9 ocr opencv computer-vision anpr
我正在使用OpenCV开发一个ANPR系统,并在一些文章中看到了一种进行字符分割的方法.我们的想法是制作一个图表,显示图像上的颜色浓度.
我该怎么做呢?
这是我的形象:
我需要检测如上所示的黑色区域的位置以识别每个字符.
我已经尝试逐个像素地添加值,但我在Android上这样做,这需要时间是不可接受的.
好吧,一个月之后,但我为此写了一些代码(在python中);)
(假设你刚好在图像密度直方图之后)
import cv
im2 = cv.LoadImage('ph05l.jpg')
width, height = cv.GetSize(im2)
hist = []
column_width = 1 # this allows you to speed up the result,
# at the expense of horizontal resolution. (higher is faster)
for x in xrange(width / column_width):
column = cv.GetSubRect(im2, (x * column_width, 0, column_width, height))
hist.append(sum(cv.Sum(column)) / 3)
Run Code Online (Sandbox Code Playgroud)
为了加快速度,你不需要改变你的图像文件,只需改变采样的bin宽度(column_width
在脚本中),显然你会失去一些分辨率(如下图所示).
在图像中,我hist
用你的文件显示结果(图形),使用1,10 column_width
和100.他们分别以0.11,0.02和0.01秒为我跑.
我也用PIL写了它,但它运行速度慢了5到10倍.