Atualli commited on
Commit
306ee79
·
1 Parent(s): 40abeda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -9
app.py CHANGED
@@ -30,6 +30,35 @@ def unsharp_mask(image, kernel_size=(5, 5), sigma=1.0, amount=1.0, threshold=0):
30
  np.copyto(sharpened, image, where=low_contrast_mask)
31
  return sharpened
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  def increase_brightness(img, value):
34
  hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
35
  h, s, v = cv2.split(hsv)
@@ -66,15 +95,8 @@ def execute_text_recognition_tflite( boxes, frame, interpreter, input_details, o
66
  if not len(text): return
67
  license_plate = text
68
  text[:3].replace("0",'O')
69
-
70
- if len(text) > 7:
71
- if len(text) >= 9:
72
- text = text[1:8]
73
- else :
74
- if text[3].isdigit() :
75
- text = text[:7]
76
- else :
77
- text = text[1:]
78
 
79
  return text,cv2.resize(save_frame,(94,24))
80
 
 
30
  np.copyto(sharpened, image, where=low_contrast_mask)
31
  return sharpened
32
 
33
+ def convdigplate(text) :
34
+ dict = {'0':'O','1':'I','2':'S','3':'E','4':'A','5':'S','6':'B','7':'T','8':'B','9':'B'}
35
+
36
+ dictL = {'A':'4','B':'8','C':'0','D':'0','E':'3','F':'3','G':'6','H':'4','I':'1',
37
+ 'J':'6','K':'4','L':'1','M':'4','N':'4','O':'0','P':'8','Q':'0','R':'8',
38
+ 'S':'2','T':'1','U':'0','V':'4','X':'4','Y':'9','W':'3','Z':'2'}
39
+
40
+ if len(text) > 7:
41
+ if len(text) >= 9:
42
+ text = text[1:8]
43
+ else :
44
+ if text[3].isdigit() :
45
+ text = text[:7]
46
+ else :
47
+ text = text[1:]
48
+
49
+ temp = list(text)
50
+
51
+ for index in range(len(temp)):
52
+ if index <3:
53
+ if text[index].isdigit():
54
+ temp[index] = dict[temp[index]]
55
+ else :
56
+ if not text[index].isdigit() and index <> 4:
57
+ temp[index] = dictL[temp[index]]
58
+
59
+ text = "".join(temp)
60
+ return text
61
+
62
  def increase_brightness(img, value):
63
  hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
64
  h, s, v = cv2.split(hsv)
 
95
  if not len(text): return
96
  license_plate = text
97
  text[:3].replace("0",'O')
98
+
99
+ text = convdigplate(text)
 
 
 
 
 
 
 
100
 
101
  return text,cv2.resize(save_frame,(94,24))
102