Browse Source

init

pull/1/MERGE
jackyu 7 years ago
parent
commit
088171eaae
100 changed files with 137 additions and 1 deletions
  1. BIN
      Font/platech.ttf
  2. +23
    -1
      README.md
  3. +17
    -0
      batch.py
  4. +97
    -0
      benchmark.py
  5. BIN
      cache/bad2/川QEZ982.png
  6. BIN
      cache/bad2/沪A85J08.png
  7. BIN
      cache/bad2/沪B14292.png
  8. BIN
      cache/bad2/沪B74992.png
  9. BIN
      cache/bad2/沪BE3658.png
  10. BIN
      cache/bad2/沪BE4823.png
  11. BIN
      cache/bad2/沪C91620.png
  12. BIN
      cache/bad2/沪CT8805.png
  13. BIN
      cache/bad2/沪D47466.png
  14. BIN
      cache/bad2/沪D49228.png
  15. BIN
      cache/bad2/沪D64396.png
  16. BIN
      cache/bad2/沪D96625.png
  17. BIN
      cache/bad2/沪DA3529.png
  18. BIN
      cache/bad2/沪DB8392.png
  19. BIN
      cache/bad2/沪DE9133.png
  20. BIN
      cache/bad2/沪LS6555.png
  21. BIN
      cache/bad2/浙A00384.png
  22. BIN
      cache/bad2/浙A077AY.png
  23. BIN
      cache/bad2/浙A0A353.png
  24. BIN
      cache/bad2/浙A197E7.png
  25. BIN
      cache/bad2/浙A199N1.png
  26. BIN
      cache/bad2/浙A1A085.png
  27. BIN
      cache/bad2/浙A1MQ29.png
  28. BIN
      cache/bad2/浙A201S2.png
  29. BIN
      cache/bad2/浙A205LK.png
  30. BIN
      cache/bad2/浙A3A570.png
  31. BIN
      cache/bad2/浙A3B213.png
  32. BIN
      cache/bad2/浙A3BR15.png
  33. BIN
      cache/bad2/浙A3DP91.png
  34. BIN
      cache/bad2/浙A3E732.png
  35. BIN
      cache/bad2/浙A3GK73.png
  36. BIN
      cache/bad2/浙A3ZM60.png
  37. BIN
      cache/bad2/浙A40924.png
  38. BIN
      cache/bad2/浙A502CX.png
  39. BIN
      cache/bad2/浙A509ZN.png
  40. BIN
      cache/bad2/浙A5709F.png
  41. BIN
      cache/bad2/浙A5770D.png
  42. BIN
      cache/bad2/浙A6UD87.png
  43. BIN
      cache/bad2/浙A71W58.png
  44. BIN
      cache/bad2/浙A727UU.png
  45. BIN
      cache/bad2/浙A7EB28.png
  46. BIN
      cache/bad2/浙A7F908.png
  47. BIN
      cache/bad2/浙A8DW01.png
  48. BIN
      cache/bad2/浙A8NC86.png
  49. BIN
      cache/bad2/浙A908BE.png
  50. BIN
      cache/bad2/浙A977K7.png
  51. BIN
      cache/bad2/浙AA9M52.png
  52. BIN
      cache/bad2/浙AAQ185.png
  53. BIN
      cache/bad2/浙AB8Y02.png
  54. BIN
      cache/bad2/浙AE5Z68.png
  55. BIN
      cache/bad2/浙AHD113.png
  56. BIN
      cache/bad2/浙AHH150.png
  57. BIN
      cache/bad2/浙AHV989.png
  58. BIN
      cache/bad2/浙AJ509M.png
  59. BIN
      cache/bad2/浙AJ9454.png
  60. BIN
      cache/bad2/浙AL0A26.png
  61. BIN
      cache/bad2/浙AL270V.png
  62. BIN
      cache/bad2/浙AM530Y.png
  63. BIN
      cache/bad2/浙AQ5855.png
  64. BIN
      cache/bad2/浙AQ7007.png
  65. BIN
      cache/bad2/浙ASM539.png
  66. BIN
      cache/bad2/浙AT039E.png
  67. BIN
      cache/bad2/浙AU8B07.png
  68. BIN
      cache/bad2/浙AUE830.png
  69. BIN
      cache/bad2/浙AY3E97.png
  70. BIN
      cache/bad2/浙AY836H.png
  71. BIN
      cache/bad2/浙AZ557H.png
  72. BIN
      cache/bad2/浙AZ6R27.png
  73. BIN
      cache/bad2/浙CL2J67.png
  74. BIN
      cache/bad2/浙DDD691.png
  75. BIN
      cache/bad2/浙DVE625.png
  76. BIN
      cache/bad2/浙DX0L91.png
  77. BIN
      cache/bad2/浙DX9H10.png
  78. BIN
      cache/bad2/浙E13183.png
  79. BIN
      cache/bad2/浙E19333.png
  80. BIN
      cache/bad2/浙E2230H.png
  81. BIN
      cache/bad2/浙E3489E.png
  82. BIN
      cache/bad2/浙E3679Z.png
  83. BIN
      cache/bad2/浙E37178.png
  84. BIN
      cache/bad2/浙E3899D.png
  85. BIN
      cache/bad2/浙E5183N.png
  86. BIN
      cache/bad2/浙E58556.png
  87. BIN
      cache/bad2/浙E6961E.png
  88. BIN
      cache/bad2/浙E7900H.png
  89. BIN
      cache/bad2/浙E8389Y.png
  90. BIN
      cache/bad2/浙EA3262.png
  91. BIN
      cache/bad2/浙EA5375.png
  92. BIN
      cache/bad2/浙EA6929.png
  93. BIN
      cache/bad2/浙EA7581.png
  94. BIN
      cache/bad2/浙EAD017.png
  95. BIN
      cache/bad2/浙EAS529.png
  96. BIN
      cache/bad2/浙EDD128.png
  97. BIN
      cache/bad2/浙EG0257.png
  98. BIN
      cache/bad2/浙EG6059.png
  99. BIN
      cache/bad2/浙EJ5933.png
  100. BIN
      cache/bad2/浙EK1921.png

BIN
Font/platech.ttf View File


+ 23
- 1
README.md View File

@@ -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)
```

+ 17
- 0
batch.py View File

@@ -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)

+ 97
- 0
benchmark.py View File

@@ -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)

BIN
cache/bad2/川QEZ982.png View File

Before After
Width: 650  |  Height: 580  |  Size: 374 kB

BIN
cache/bad2/沪A85J08.png View File

Before After
Width: 650  |  Height: 580  |  Size: 318 kB

BIN
cache/bad2/沪B14292.png View File

Before After
Width: 650  |  Height: 580  |  Size: 247 kB

BIN
cache/bad2/沪B74992.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.7 MB

BIN
cache/bad2/沪BE3658.png View File

Before After
Width: 650  |  Height: 580  |  Size: 337 kB

BIN
cache/bad2/沪BE4823.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.9 MB

BIN
cache/bad2/沪C91620.png View File

Before After
Width: 650  |  Height: 580  |  Size: 364 kB

BIN
cache/bad2/沪CT8805.png View File

Before After
Width: 650  |  Height: 580  |  Size: 331 kB

BIN
cache/bad2/沪D47466.png View File

Before After
Width: 650  |  Height: 580  |  Size: 250 kB

BIN
cache/bad2/沪D49228.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.5 MB

BIN
cache/bad2/沪D64396.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.8 MB

BIN
cache/bad2/沪D96625.png View File

Before After
Width: 650  |  Height: 580  |  Size: 316 kB

BIN
cache/bad2/沪DA3529.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.8 MB

BIN
cache/bad2/沪DB8392.png View File

Before After
Width: 650  |  Height: 580  |  Size: 286 kB

BIN
cache/bad2/沪DE9133.png View File

Before After
Width: 650  |  Height: 580  |  Size: 353 kB

BIN
cache/bad2/沪LS6555.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.5 MB

BIN
cache/bad2/浙A00384.png View File

Before After
Width: 650  |  Height: 580  |  Size: 326 kB

BIN
cache/bad2/浙A077AY.png View File

Before After
Width: 650  |  Height: 580  |  Size: 341 kB

BIN
cache/bad2/浙A0A353.png View File

Before After
Width: 650  |  Height: 580  |  Size: 297 kB

BIN
cache/bad2/浙A197E7.png View File

Before After
Width: 650  |  Height: 580  |  Size: 373 kB

BIN
cache/bad2/浙A199N1.png View File

Before After
Width: 650  |  Height: 580  |  Size: 334 kB

BIN
cache/bad2/浙A1A085.png View File

Before After
Width: 650  |  Height: 580  |  Size: 367 kB

BIN
cache/bad2/浙A1MQ29.png View File

Before After
Width: 650  |  Height: 580  |  Size: 308 kB

BIN
cache/bad2/浙A201S2.png View File

Before After
Width: 650  |  Height: 580  |  Size: 351 kB

BIN
cache/bad2/浙A205LK.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.6 MB

BIN
cache/bad2/浙A3A570.png View File

Before After
Width: 650  |  Height: 580  |  Size: 295 kB

BIN
cache/bad2/浙A3B213.png View File

Before After
Width: 650  |  Height: 580  |  Size: 336 kB

BIN
cache/bad2/浙A3BR15.png View File

Before After
Width: 650  |  Height: 580  |  Size: 323 kB

BIN
cache/bad2/浙A3DP91.png View File

Before After
Width: 650  |  Height: 580  |  Size: 302 kB

BIN
cache/bad2/浙A3E732.png View File

Before After
Width: 650  |  Height: 580  |  Size: 365 kB

BIN
cache/bad2/浙A3GK73.png View File

Before After
Width: 650  |  Height: 580  |  Size: 386 kB

BIN
cache/bad2/浙A3ZM60.png View File

Before After
Width: 650  |  Height: 580  |  Size: 300 kB

BIN
cache/bad2/浙A40924.png View File

Before After
Width: 650  |  Height: 580  |  Size: 300 kB

BIN
cache/bad2/浙A502CX.png View File

Before After
Width: 650  |  Height: 580  |  Size: 400 kB

BIN
cache/bad2/浙A509ZN.png View File

Before After
Width: 650  |  Height: 580  |  Size: 319 kB

BIN
cache/bad2/浙A5709F.png View File

Before After
Width: 650  |  Height: 580  |  Size: 352 kB

BIN
cache/bad2/浙A5770D.png View File

Before After
Width: 650  |  Height: 580  |  Size: 363 kB

BIN
cache/bad2/浙A6UD87.png View File

Before After
Width: 650  |  Height: 580  |  Size: 374 kB

BIN
cache/bad2/浙A71W58.png View File

Before After
Width: 650  |  Height: 580  |  Size: 327 kB

BIN
cache/bad2/浙A727UU.png View File

Before After
Width: 650  |  Height: 580  |  Size: 354 kB

BIN
cache/bad2/浙A7EB28.png View File

Before After
Width: 650  |  Height: 580  |  Size: 375 kB

BIN
cache/bad2/浙A7F908.png View File

Before After
Width: 650  |  Height: 580  |  Size: 315 kB

BIN
cache/bad2/浙A8DW01.png View File

Before After
Width: 650  |  Height: 580  |  Size: 266 kB

BIN
cache/bad2/浙A8NC86.png View File

Before After
Width: 650  |  Height: 580  |  Size: 278 kB

BIN
cache/bad2/浙A908BE.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.6 MB

BIN
cache/bad2/浙A977K7.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.5 MB

BIN
cache/bad2/浙AA9M52.png View File

Before After
Width: 650  |  Height: 580  |  Size: 341 kB

BIN
cache/bad2/浙AAQ185.png View File

Before After
Width: 650  |  Height: 580  |  Size: 308 kB

BIN
cache/bad2/浙AB8Y02.png View File

Before After
Width: 650  |  Height: 580  |  Size: 359 kB

BIN
cache/bad2/浙AE5Z68.png View File

Before After
Width: 650  |  Height: 580  |  Size: 317 kB

BIN
cache/bad2/浙AHD113.png View File

Before After
Width: 650  |  Height: 580  |  Size: 368 kB

BIN
cache/bad2/浙AHH150.png View File

Before After
Width: 650  |  Height: 580  |  Size: 337 kB

BIN
cache/bad2/浙AHV989.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.7 MB

BIN
cache/bad2/浙AJ509M.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.8 MB

BIN
cache/bad2/浙AJ9454.png View File

Before After
Width: 650  |  Height: 580  |  Size: 308 kB

BIN
cache/bad2/浙AL0A26.png View File

Before After
Width: 650  |  Height: 580  |  Size: 352 kB

BIN
cache/bad2/浙AL270V.png View File

Before After
Width: 650  |  Height: 580  |  Size: 302 kB

BIN
cache/bad2/浙AM530Y.png View File

Before After
Width: 650  |  Height: 580  |  Size: 315 kB

BIN
cache/bad2/浙AQ5855.png View File

Before After
Width: 650  |  Height: 580  |  Size: 290 kB

BIN
cache/bad2/浙AQ7007.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 1.4 MB

BIN
cache/bad2/浙ASM539.png View File

Before After
Width: 650  |  Height: 580  |  Size: 318 kB

BIN
cache/bad2/浙AT039E.png View File

Before After
Width: 650  |  Height: 580  |  Size: 335 kB

BIN
cache/bad2/浙AU8B07.png View File

Before After
Width: 650  |  Height: 580  |  Size: 253 kB

BIN
cache/bad2/浙AUE830.png View File

Before After
Width: 650  |  Height: 580  |  Size: 262 kB

BIN
cache/bad2/浙AY3E97.png View File

Before After
Width: 650  |  Height: 580  |  Size: 377 kB

BIN
cache/bad2/浙AY836H.png View File

Before After
Width: 650  |  Height: 580  |  Size: 321 kB

BIN
cache/bad2/浙AZ557H.png View File

Before After
Width: 650  |  Height: 580  |  Size: 288 kB

BIN
cache/bad2/浙AZ6R27.png View File

Before After
Width: 1600  |  Height: 1200  |  Size: 2.0 MB

BIN
cache/bad2/浙CL2J67.png View File

Before After
Width: 650  |  Height: 580  |  Size: 390 kB

BIN
cache/bad2/浙DDD691.png View File

Before After
Width: 650  |  Height: 580  |  Size: 327 kB

BIN
cache/bad2/浙DVE625.png View File

Before After
Width: 650  |  Height: 580  |  Size: 345 kB

BIN
cache/bad2/浙DX0L91.png View File

Before After
Width: 650  |  Height: 580  |  Size: 297 kB

BIN
cache/bad2/浙DX9H10.png View File

Before After
Width: 650  |  Height: 580  |  Size: 355 kB

BIN
cache/bad2/浙E13183.png View File

Before After
Width: 650  |  Height: 580  |  Size: 290 kB

BIN
cache/bad2/浙E19333.png View File

Before After
Width: 650  |  Height: 580  |  Size: 309 kB

BIN
cache/bad2/浙E2230H.png View File

Before After
Width: 650  |  Height: 580  |  Size: 356 kB

BIN
cache/bad2/浙E3489E.png View File

Before After
Width: 650  |  Height: 580  |  Size: 326 kB

BIN
cache/bad2/浙E3679Z.png View File

Before After
Width: 650  |  Height: 580  |  Size: 423 kB

BIN
cache/bad2/浙E37178.png View File

Before After
Width: 650  |  Height: 580  |  Size: 340 kB

BIN
cache/bad2/浙E3899D.png View File

Before After
Width: 650  |  Height: 580  |  Size: 360 kB

BIN
cache/bad2/浙E5183N.png View File

Before After
Width: 650  |  Height: 580  |  Size: 300 kB

BIN
cache/bad2/浙E58556.png View File

Before After
Width: 650  |  Height: 580  |  Size: 297 kB

BIN
cache/bad2/浙E6961E.png View File

Before After
Width: 650  |  Height: 580  |  Size: 378 kB

BIN
cache/bad2/浙E7900H.png View File

Before After
Width: 650  |  Height: 580  |  Size: 320 kB

BIN
cache/bad2/浙E8389Y.png View File

Before After
Width: 650  |  Height: 580  |  Size: 392 kB

BIN
cache/bad2/浙EA3262.png View File

Before After
Width: 650  |  Height: 580  |  Size: 275 kB

BIN
cache/bad2/浙EA5375.png View File

Before After
Width: 650  |  Height: 580  |  Size: 258 kB

BIN
cache/bad2/浙EA6929.png View File

Before After
Width: 650  |  Height: 580  |  Size: 304 kB

BIN
cache/bad2/浙EA7581.png View File

Before After
Width: 650  |  Height: 580  |  Size: 281 kB

BIN
cache/bad2/浙EAD017.png View File

Before After
Width: 650  |  Height: 580  |  Size: 324 kB

BIN
cache/bad2/浙EAS529.png View File

Before After
Width: 650  |  Height: 580  |  Size: 280 kB

BIN
cache/bad2/浙EDD128.png View File

Before After
Width: 650  |  Height: 580  |  Size: 294 kB

BIN
cache/bad2/浙EG0257.png View File

Before After
Width: 650  |  Height: 580  |  Size: 374 kB

BIN
cache/bad2/浙EG6059.png View File

Before After
Width: 650  |  Height: 580  |  Size: 244 kB

BIN
cache/bad2/浙EJ5933.png View File

Before After
Width: 650  |  Height: 580  |  Size: 252 kB

BIN
cache/bad2/浙EK1921.png View File

Before After
Width: 650  |  Height: 580  |  Size: 344 kB

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save