-
Notifications
You must be signed in to change notification settings - Fork 20
/
demo.py
39 lines (29 loc) · 1.02 KB
/
demo.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
import os
import platform
from TaiwanTrainVerificationCode2text import verification_code2text
from TaiwanTrainVerificationCode2text import work_vcode
from TaiwanTrainVerificationCode2text import download
import TaiwanTrainVerificationCode2text
PATH = TaiwanTrainVerificationCode2text.__path__[0]
import cv2
import matplotlib.pyplot as plt
import random
from datetime import datetime
download.weight()
download.ttf()
work_vcode.work_vcode_fun(10,'test_data',5)
work_vcode.work_vcode_fun(10,'test_data',6)
if 'Windows' in platform.platform():
file_path = '{}/{}/'.format(PATH,'test_data')
train_image_path = [file_path + i for i in os.listdir(file_path+'/')]
else:
file_path = '{}\\{}\\'.format(PATH,'test_data')
train_image_path = [file_path + i for i in os.listdir(file_path+'\\')]
image_name = train_image_path[random.sample( range(len(train_image_path)) ,1)[0]]
s = datetime.now()
image = cv2.imread(image_name)
plt.imshow(image)
text = verification_code2text.main(image)
print(text)
t = datetime.now() - s
print(t)