-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo_streaming.py
More file actions
60 lines (51 loc) · 1.44 KB
/
video_streaming.py
File metadata and controls
60 lines (51 loc) · 1.44 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
# import the opencv library
import asyncio
import cv2
import FaceTest as fc
import time
import requests
ip="192.168.1.10:5000"
def Stream():
# define a video capture object
vid = cv2.VideoCapture(0)
while(True):
ret, frame = vid.read()
return fc.picture_anal(frame)
def Setup():
global isActive
isActive=False
def SetIp(ipAddr):
ip=ipAddr
async def Main_Run(mode, ip):
print("ip="+ip)
isActive=True
iter=0
state=[1,1,1,1,1,1,1,1,1,1,1]
while(True):
for x in range(0, 10):
state[x]=state[x+1]
state[10]=Stream()
if state.count(0)>7:
try:
if mode==0:
r = requests.get(str("http://"+ip+"/taze"), auth=('user', 'pass'))
else:
r = requests.get(str("http://"+ip+"/vibrate"), auth=('user', 'pass'))
await asyncio.sleep(0.5)
except:
return
def Test_run(mode):
isActive=True
iter=0
state=[1,1,1,1,1,1,1,1,1,1,1]
while(isActive):
for x in range(0, 10):
state[x]=state[x+1]
state[10]=fc.picture_anal(cv2.imread('test_img/stelyo2.jpg'))
if state.count(0)>7:
if mode==0:
r = requests.get(str("http://"+ip+"/taze"), auth=('user', 'pass'))
else:
r = requests.get(str("http://"+ip+"/vibrate"), auth=('user', 'pass'))
time.sleep(0.5)
#Test_run(1)