-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
41 lines (30 loc) · 1.05 KB
/
app.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
from flask import Flask, render_template, Response
from webcam import cam_stream
from image import img_gen
app = Flask(__name__)
# the starting route
@app.route('/')
def index():
return render_template('index.html')
# the function which generates frame by calling function camera_stream
def gen_frame():
while True:
frame = cam_stream()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
# function to concat all video frames and display on web-app
@app.route('/video_feed')
def video_feed():
return Response(gen_frame(),
mimetype='multipart/x-mixed-replace; boundary=frame')
'''def gen_image():
frame=img_gen()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/image_class')
def image_class():
return Response(gen_image(),
mimetype='multipart/x-mixed-replace; boundary=frame')'''
# start the host on local server
if __name__ == '__main__':
app.run(host='0.0.0.0', threaded=True)