-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_two_models.py
54 lines (42 loc) · 1.46 KB
/
app_two_models.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
from flask import Flask, render_template, Response
from streamer import Streamer
from streamer_alpha import Streamer_alpha
from streamer_canny import Streamer_canny
app = Flask(__name__)
def gen():
streamer = Streamer('0.0.0.0', 8089)
streamer.start()
while True:
if streamer.client_connected():
frame = streamer.get_jpeg()
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
def gen_alpha():
streamer = Streamer_alpha('0.0.0.0', 8087)
streamer.start()
while True:
# print(streamer.get_jpeg())
if streamer.client_connected():
frame = streamer.get_jpeg()
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
def gen_canny():
streamer = Streamer_canny('0.0.0.0', 8088)
streamer.start()
while True:
# print(streamer.get_jpeg())
if streamer.client_connected():
frame = streamer.get_jpeg()
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/')
def index():
return render_template('index.html')
@app.route('/video_feed')
def video_feed():
return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/video_feed_alpha')
def video_feed_alpha():
return Response(gen_alpha(), mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/video_feed_canny')
def video_feed_canny():
return Response(gen_canny(), mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='0.0.0.0', threaded=True)