-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsamp.py
More file actions
80 lines (60 loc) · 1.85 KB
/
Copy pathsamp.py
File metadata and controls
80 lines (60 loc) · 1.85 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# import the necessary packages
import requests
import urllib
import cv2
import json
import pyttsx3
# define the URL to our face detection API
url = "http://localhost:8000/detect/"
# use our face detection API to find faces in images via image URL
'''
cap = cv2.VideoCapture('project_video.mp4')
ret=True
count=0
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
print(type(frame),ret)
if not ret:
break
cv2.imwrite("frame.jpg",frame)
files = {'media': open("frame.jpg", 'rb')}
r = requests.post(url, files=files).json()
count=count+1
print(count)
'''
for i in range(1,4):
files = {'media': open("frame%d.jpg"%i, 'rb')}
#files = {'media': open("frame1.jpg", 'rb')}
r = requests.post(url, files=files).json()
engine = pyttsx3.init()
engine.setProperty('rate',100)
engine.setProperty('volume',1)
engine.say(r['offset'])
engine.runAndWait()
engine.say(r['obstacles'])
engine.runAndWait()
print(str(r))
# Our operations on the frame come here
# Display the resulting frame
#print(str(r))
#print("{}".format(r))
'''
# loop over the faces and draw them on the image
for (startX, startY, endX, endY) in r["faces"]:
cv2.rectangle(image, (startX, startY), (endX, endY), (0, 255, 0), 2)
# show the output image
cv2.imshow("obama.jpg", image)
cv2.waitKey(0)
# load our image and now use the face detection API to find faces in
# images by uploading an image directly
image = cv2.imread("adrian.jpg")
payload = {"image": open("adrian.jpg", "rb")}
r = requests.post(url, files=payload).json()
print "adrian.jpg: {}".format(r)
# loop over the faces and draw them on the image
for (startX, startY, endX, endY) in r["faces"]:
cv2.rectangle(image, (startX, startY), (endX, endY), (0, 255, 0), 2)
# show the output image
cv2.imshow("adrian.jpg", image)
cv2.waitKey(0)'''