-
Notifications
You must be signed in to change notification settings - Fork 119
/
app.py
30 lines (24 loc) · 849 Bytes
/
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
# Flask utils
from flask import Flask, redirect, url_for, request, render_template, Response
from werkzeug.utils import secure_filename
from gevent.pywsgi import WSGIServer
from camera import Camera
from object_detection import object_detection
app = Flask(__name__)
camera = Camera(0)
@app.route("/")
def main():
return render_template("index.html")
def gen(camera):
while True:
frame,l,feedback = camera.get_frame()
if frame != "":
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(camera), mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
# Serve the app with gevent
http_server = WSGIServer(('localhost', 5000), app)
http_server.serve_forever()