-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.py
62 lines (52 loc) · 1.53 KB
/
start.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import time
import os
import cv2
start = time.time()
#run image acquisition
print("starting...")
print("acquiring image...")
os.system('python acquireimage.py')
print("image acquired")
start1 = time.time()
os.system('python textdetect.py')
#print("Enter input type:\n1.ID CARD \n2.SIGN BOARD \n 3.")
print("preprocessing image...")
os.system('python roi1.py')
list = os.listdir('./roi/') # dir is your directory path
number_of_files = len(list)
#check if roi returned images or not
if number_of_files == 0:
image = cv2.imread('./images/sample_0.jpg')
cv2.imwrite('./roi/ROI_0.jpg', image)
#run preprocessor
os.system('python prepro.py')
end1 = time.time()
start2 = time.time()
print("running ocr...")
#run ocr
os.system('python ocr.py')
words=''
with open('text.txt', 'r') as file:
words = file.read().replace('\n', '')
words=words.replace(' ','')
end2 = time.time()
start3 = time.time()
if len(words) == 0 :
print('no text detected \n exiting..')
else :
os.system('python names.py')
#os.system('python nameidentifier.py')
print("running spell correction...")
#run spell correction
#os.system('python spell.py')
os.system('python sym1.py')
end3 = time.time()
print("running text to speech convertor...")
#run tts
os.system('python tts4.py')
end = time.time()
print(f'preprocessing: {int(end1 - start1)} seconds')
print(f'character recognition: {int(end2 - start2)} seconds')
if len(words) != 0:
print(f'postprocessing: {int(end3 - start3)} seconds')
print(f'Runtime: {int(end - start)} seconds')