-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpara.py
43 lines (33 loc) · 984 Bytes
/
para.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np
image_w = 240
image_h = 120
image_c = 3
rnn_size = 96
dense_size = 64
max_text_len = 7
CHAR_VECTOR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
letters = [letter for letter in CHAR_VECTOR]
num_classes = len(letters)
SEED = 50
def decodePlateVec(y):
vec = np.zeros((1, max_text_len), dtype=np.uint8)
for i in range(7):
vec[0, i] = np.argmax(y[:,i])
return vec
def encode_plate(string):
num = np.zeros((num_classes, max_text_len))
for i in range(len(string)):
for j in range(num_classes):
if ( string[i] == letters[j] ):
num[j,i] = 1
if (len(string) == 6):
num[num_classes-1, 6] = 1
if (len(string) == 5):
num[num_classes-1, 6] = 1
num[num_classes-1, 5] = 1
if (len(string) == 4):
num[num_classes-1, 6] = 1
num[num_classes-1, 5] = 1
num[num_classes-1, 4] = 1
#print(string, '\n', num)
return num