init
@ -1,2 +1,24 @@
|
||||
# hpyerlpr
|
||||
# 车牌识别
|
||||
|
||||
### Pipeline
|
||||
|
||||
step1. 使用opencv 的 HAAR cascade 检测车牌大致位置
|
||||
|
||||
step2. Extend 检测到的大致位置的矩形区域
|
||||
|
||||
step3. 使用类似于mser的方式的多级二值化+ransac拟合车牌的上下边界
|
||||
|
||||
step4. 使用CNN regression回归车牌左右边界
|
||||
|
||||
step5. 使用CNN滑动窗切割字符
|
||||
|
||||
step6. 使用CNN识别字符
|
||||
|
||||
### 简单测试方式
|
||||
|
||||
```python
|
||||
from hyperlpr import pipline as pp
|
||||
import cv2
|
||||
image = cv2.imread("filename")
|
||||
image,res = pp.SimpleRecognizePlate(image)
|
||||
```
|
@ -0,0 +1,17 @@
|
||||
#coding=utf-8
|
||||
import os
|
||||
from hyperlpr import pipline as pp
|
||||
|
||||
import cv2
|
||||
|
||||
parent= "/Users/yujinke/车牌图片/收费站_完成标注"
|
||||
|
||||
for filename in os.listdir(parent):
|
||||
path = os.path.join(parent,filename)
|
||||
print path
|
||||
if path.endswith(".jpg") or path.endswith(".png"):
|
||||
image = cv2.imread(path)
|
||||
|
||||
image,res = pp.SimpleRecognizePlate(image)
|
||||
cv2.imshow("image",image)
|
||||
cv2.waitKey(0)
|
@ -0,0 +1,97 @@
|
||||
#coding=utf-8
|
||||
import os
|
||||
import numpy as np
|
||||
import cv2
|
||||
import json
|
||||
from hyperlpr import pipline as pp
|
||||
import sys
|
||||
from Levenshtein import StringMatcher as sm
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding("utf-8")
|
||||
# parent= "/Users/yujinke/车牌图片/云南车牌"
|
||||
parent= "/Users/yujinke/车牌图片/收费站_完成标注"
|
||||
|
||||
# parent= "./cache/bad2"
|
||||
|
||||
|
||||
|
||||
|
||||
def comparestring(a,b):
|
||||
g = 0
|
||||
if len(a) == len(b):
|
||||
for x,y in zip(a,b):
|
||||
if x!=y:
|
||||
g+=1
|
||||
return g
|
||||
|
||||
|
||||
count = 0 ;
|
||||
|
||||
count_p = 0
|
||||
count_d = 0
|
||||
count_lev = 0
|
||||
count_undetected = 0
|
||||
|
||||
roi = [470,400,650,580]
|
||||
|
||||
for filename in os.listdir(parent):
|
||||
|
||||
path = os.path.join(parent,filename)
|
||||
print path
|
||||
|
||||
if path.endswith(".jpg") or path.endswith(".png"):
|
||||
ics,name = os.path.split(path)
|
||||
|
||||
|
||||
name,ext = name.split(".")
|
||||
|
||||
image = cv2.imread(path)
|
||||
image = image[roi[1]:roi[1]+roi[3],roi[0]:roi[0]+roi[2]]
|
||||
# cv2.imshow("test",image)
|
||||
# cv2.waitKey(0)
|
||||
info,dataset = pp.SimpleRecognizePlate(image)
|
||||
ext = ext.strip()
|
||||
name = name.strip()
|
||||
|
||||
if len(dataset)==0:
|
||||
count_undetected +=1
|
||||
|
||||
# cv2.imwrite("./cache/bad2/" + name + ".png", image)
|
||||
|
||||
for one in dataset:
|
||||
|
||||
# p = sm.StringMatcher(seq1=one.encode("utf-8"),seq2=name.encode("utf-8"))
|
||||
A = one.encode("utf-8")
|
||||
B = name.encode("utf-8")
|
||||
print one.encode("utf-8"),"<->",name.encode("utf-8"),"编辑距离:",comparestring(A,B)
|
||||
if comparestring(A,B)<2:
|
||||
count_lev+=1
|
||||
if one.encode("utf-8") == name.encode("utf-8"):
|
||||
count_p+=1
|
||||
break
|
||||
else:
|
||||
print "error",one.encode("utf-8"), name.encode("utf-8")
|
||||
count_d+=1
|
||||
# cv2.imshow("image",image)
|
||||
# cv2.waitKey(0)
|
||||
cv2.imwrite("./cache/bad2/"+name+".png",image)
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
count+=1
|
||||
print count_p / float(count),"编辑距离[1]:",count_lev/float(count),u"识出",count_p,u"总数",count,u"未识出",count_d,u"未检测出",count_undetected
|
||||
|
||||
if count_p+count_d+count_undetected!=count:
|
||||
print dataset,len(dataset)
|
||||
exit(0)
|
||||
|
||||
|
||||
#
|
||||
# cv2.imshow("image",image)
|
||||
# cv2.waitKey(0)
|
||||
|
||||
# print count_p/float(count)
|
After Width: | Height: | Size: 365 KiB |
After Width: | Height: | Size: 311 KiB |
After Width: | Height: | Size: 242 KiB |
After Width: | Height: | Size: 1.6 MiB |
After Width: | Height: | Size: 329 KiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 355 KiB |
After Width: | Height: | Size: 324 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 309 KiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 279 KiB |
After Width: | Height: | Size: 345 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 318 KiB |
After Width: | Height: | Size: 333 KiB |
After Width: | Height: | Size: 290 KiB |
After Width: | Height: | Size: 365 KiB |
After Width: | Height: | Size: 326 KiB |
After Width: | Height: | Size: 358 KiB |
After Width: | Height: | Size: 301 KiB |
After Width: | Height: | Size: 343 KiB |
After Width: | Height: | Size: 1.6 MiB |
After Width: | Height: | Size: 288 KiB |
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 315 KiB |
After Width: | Height: | Size: 295 KiB |
After Width: | Height: | Size: 356 KiB |
After Width: | Height: | Size: 377 KiB |
After Width: | Height: | Size: 293 KiB |
After Width: | Height: | Size: 293 KiB |
After Width: | Height: | Size: 391 KiB |
After Width: | Height: | Size: 312 KiB |
After Width: | Height: | Size: 344 KiB |
After Width: | Height: | Size: 355 KiB |
After Width: | Height: | Size: 365 KiB |
After Width: | Height: | Size: 319 KiB |
After Width: | Height: | Size: 346 KiB |
After Width: | Height: | Size: 366 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 260 KiB |
After Width: | Height: | Size: 272 KiB |
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 333 KiB |
After Width: | Height: | Size: 301 KiB |
After Width: | Height: | Size: 350 KiB |
After Width: | Height: | Size: 310 KiB |
After Width: | Height: | Size: 359 KiB |
After Width: | Height: | Size: 329 KiB |
After Width: | Height: | Size: 1.6 MiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 301 KiB |
After Width: | Height: | Size: 344 KiB |
After Width: | Height: | Size: 295 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 283 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 311 KiB |
After Width: | Height: | Size: 327 KiB |
After Width: | Height: | Size: 247 KiB |
After Width: | Height: | Size: 255 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 314 KiB |
After Width: | Height: | Size: 281 KiB |
After Width: | Height: | Size: 1.9 MiB |
After Width: | Height: | Size: 381 KiB |
After Width: | Height: | Size: 319 KiB |
After Width: | Height: | Size: 337 KiB |
After Width: | Height: | Size: 290 KiB |
After Width: | Height: | Size: 347 KiB |
After Width: | Height: | Size: 283 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 348 KiB |
After Width: | Height: | Size: 318 KiB |
After Width: | Height: | Size: 413 KiB |
After Width: | Height: | Size: 332 KiB |
After Width: | Height: | Size: 351 KiB |
After Width: | Height: | Size: 293 KiB |
After Width: | Height: | Size: 290 KiB |
After Width: | Height: | Size: 369 KiB |
After Width: | Height: | Size: 313 KiB |
After Width: | Height: | Size: 383 KiB |
After Width: | Height: | Size: 269 KiB |
After Width: | Height: | Size: 252 KiB |
After Width: | Height: | Size: 297 KiB |
After Width: | Height: | Size: 274 KiB |
After Width: | Height: | Size: 317 KiB |
After Width: | Height: | Size: 273 KiB |
After Width: | Height: | Size: 287 KiB |
After Width: | Height: | Size: 365 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 246 KiB |
After Width: | Height: | Size: 336 KiB |