client zeug
This commit is contained in:
parent
f2553b7067
commit
6ed5ff1046
|
|
@ -2,48 +2,35 @@ from flask import Flask, request
|
|||
import os
|
||||
import simpleaudio as sa
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# App Config.
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Controllers.
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
p = None
|
||||
w = None
|
||||
w = sa.WaveObject.from_wave_file("./rave.wav")
|
||||
playing = False
|
||||
|
||||
@app.route('/play')
|
||||
def index():
|
||||
global p, playing
|
||||
playing = True
|
||||
print("yes")
|
||||
p = w.play()
|
||||
global playing, p, w
|
||||
if playing:
|
||||
return 406
|
||||
if not playing:
|
||||
else:
|
||||
playing = True
|
||||
p = w.play()
|
||||
return 200
|
||||
|
||||
@app.route('/stop')
|
||||
def test():
|
||||
global p, playing
|
||||
playing = False
|
||||
p.stop()
|
||||
global playing, p
|
||||
if playing:
|
||||
return 200
|
||||
if not playing:
|
||||
else:
|
||||
playing = False
|
||||
p.stop()
|
||||
return 406
|
||||
|
||||
if __name__ == '__main__':
|
||||
port = int(os.environ.get('PORT', 80))
|
||||
global p
|
||||
global w
|
||||
w = sa.WaveObject.from_wave_file("./rave.wav")
|
||||
|
||||
app.run(host='0.0.0.0', port=port)
|
||||
|
||||
port = int(os.environ.get('PORT', 81))
|
||||
app.run(host='0.0.0.0', port=port)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
BIN
client/rave.mp3
BIN
client/rave.mp3
Binary file not shown.
|
|
@ -5,8 +5,7 @@ import requests
|
|||
import detector as dt
|
||||
import cv2
|
||||
import _thread
|
||||
import copy
|
||||
from flask import Flask, jsonify, Response, make_response, send_file
|
||||
from flask import Flask, jsonify, Response, send_file
|
||||
|
||||
######### ###########
|
||||
### Init ###
|
||||
|
|
@ -49,12 +48,13 @@ def gen(camera):
|
|||
|
||||
def main():
|
||||
detector = dt.Detector()
|
||||
t = 1 # seconds a person can leave the room for
|
||||
t0 = time.time()
|
||||
elapsed = 0
|
||||
|
||||
while True:
|
||||
for cam in cams:
|
||||
t = 1 # seconds a person can leave the room for
|
||||
t0 = time.time()
|
||||
time.clock()
|
||||
elapsed = 0
|
||||
|
||||
stream = cam["ip"]
|
||||
|
||||
clientStatus = clients[cam["client_id"]]["status"]
|
||||
|
|
@ -63,10 +63,10 @@ def main():
|
|||
elapsed = time.time() - t0
|
||||
if elapsed > t and clientStatus:
|
||||
try:
|
||||
#r = requests.get(clientIp + "/stop")
|
||||
#if r.status_code == 200:
|
||||
clients[cam["client_id"]]["status"] = False
|
||||
cam["status"] = False
|
||||
r = requests.get(clientIp + "/stop")
|
||||
if r.status_code == 200:
|
||||
clients[cam["client_id"]]["status"] = False
|
||||
cam["status"] = False
|
||||
except:
|
||||
print("request error")
|
||||
|
||||
|
|
@ -77,11 +77,11 @@ def main():
|
|||
|
||||
if result and not clientStatus:
|
||||
try:
|
||||
#r = requests.get(clientIp + "/play")
|
||||
#if r.status_code == 200:
|
||||
clients[cam["client_id"]]["status"] = True
|
||||
cam["status"] = True
|
||||
t0 = time.time()
|
||||
r = requests.get(clientIp + "/play")
|
||||
if r.status_code == 200:
|
||||
clients[cam["client_id"]]["status"] = True
|
||||
cam["status"] = True
|
||||
t0 = time.time()
|
||||
except:
|
||||
print("request error")
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"label": "cam1",
|
||||
"ip": "http://89.29.108.38:80/mjpg/video.mjpg",
|
||||
"client_id": 0,
|
||||
"status": true,
|
||||
"status": false,
|
||||
"x":0.2,
|
||||
"y":0.8,
|
||||
"angle": 130
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"label": "cam3",
|
||||
"ip": "http://62.99.80.154:81/mjpg/video.mjpg",
|
||||
"client_id": 2,
|
||||
"status": true,
|
||||
"status": false,
|
||||
"x":0.9,
|
||||
"y":0.1,
|
||||
"angle": 270
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
{
|
||||
"id": 0,
|
||||
"label": "name1",
|
||||
"ip": "http://127.0.0.2",
|
||||
"status": true,
|
||||
"ip": "",
|
||||
"status": false,
|
||||
"x":0.11,
|
||||
"y":0.8
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"label": "name2",
|
||||
"ip": "http://127.0.0.2",
|
||||
"ip": "http://127.0.0.1:81",
|
||||
"status": false,
|
||||
"x":0.3,
|
||||
"y":0.3
|
||||
|
|
@ -18,8 +18,8 @@
|
|||
{
|
||||
"id": 2,
|
||||
"label": "name3",
|
||||
"ip": "http://127.0.0.2",
|
||||
"status": true,
|
||||
"ip": "",
|
||||
"status": false,
|
||||
"x":0.5,
|
||||
"y":0.6
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class Detector:
|
|||
|
||||
def detect(self, stream):
|
||||
cap = cv2.VideoCapture(stream)
|
||||
img = None
|
||||
r, img = cap.read()
|
||||
if img is None:
|
||||
return img
|
||||
|
|
@ -73,8 +74,6 @@ class Detector:
|
|||
|
||||
boxes, scores, classes, num = self.odapi.process_frame(img)
|
||||
|
||||
# Visualization of the results of a detection.
|
||||
|
||||
for i in range(len(boxes)):
|
||||
# Class 1 represents human
|
||||
if classes[i] == 1:
|
||||
|
|
@ -84,7 +83,7 @@ class Detector:
|
|||
return img, True
|
||||
else:
|
||||
return img, False
|
||||
# cv2.imshow("preeview", img) # cv2.destroyWindow("preview")
|
||||
|
||||
|
||||
#def __del__(self):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue