-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
60 lines (52 loc) · 1.44 KB
/
test.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
# Impporting dependecies
import os
import sys
import subprocess
import cv2
import random
import time
import pyttsx
# testimg function is created
def testimg():
# printing the number of seconds left
count = reversed(range(1 , 4))
for i in count:
print("T-minus", i)
time.sleep(1)
# random number is generated
randn = random.randint(1,100)
#camera settings are configured
camera_port = 0
ramp_frames = 30
camera = cv2.VideoCapture(camera_port)
def get_image():
retval, im = camera.read()
return im
for i in range(ramp_frames):
temp = get_image()
# Take the Photo
print("Taking image...")
time.sleep(0.01) # sleep time of 0.01 secs
camera_capture = get_image()
img_test = "_image" + str(randn) + ".jpg" #one photo taken to test
# test photos are stored inside Test_img folder
file = "D:/WorkArea/GitHub/tensorflow-for-poets-2/tf_files/Test_img/" + img_test
cv2.imwrite(file, camera_capture)
del(camera)
print("Testing..")
for i in range(1, 100):
print(i * "*")
time.sleep(0.001)
# Classifying
os.system("python -m scripts.label_image --graph=tf_files/retrained_graph.pb --image=tf_files/Test_img/" + img_test)
with open('results.txt', 'r') as f:
first_line = f.readline()
print(first_line) # printing the first line
print(type(first_line))
# speech engine is initialized
engine = pyttsx.init()
engine.say("I am pretty sure you are")
time.sleep(0.05)
engine.say(first_line)
engine.runAndWait()
#testimg()