Change rendering and fix minor bug
Change-Id: Ibc5f1b6785b71d18940f9e8868f8b4dbb2ba4e5f
diff --git a/person_detection/app.py b/person_detection/app.py
index 240c450..b1e9b2d 100644
--- a/person_detection/app.py
+++ b/person_detection/app.py
@@ -5,21 +5,25 @@
"""
from importlib import import_module
import os
-from flask import Flask, render_template, Response
+import logging as log
+import sys
+import flask
from argparse import ArgumentParser, SUPPRESS
import config
from person_detection import Camera
+import roc
-app = Flask(__name__)
+app = flask.Flask(__name__)
@app.route('/')
def index():
global cameras
"""Video streaming home page."""
- return render_template('index.html', devices=config.cameras)
+ log.info("{} - connected".format(flask.request.remote_addr))
+ return flask.render_template('index.html', devices=config.cameras)
def gen(camera):
"""Video streaming generator function."""
@@ -32,8 +36,9 @@
def video_feed(device):
"""Video streaming route. Put this in the src attribute of an img tag."""
global args
- camera = Camera(device, args)
- return Response(gen(camera),
+ log.debug("{} - video feed {}".format(flask.request.remote_addr, device))
+ camera = Camera(device, flask.request.remote_addr, args)
+ return flask.Response(gen(camera),
mimetype='multipart/x-mixed-replace; boundary=frame')
def name_to_port(name):
@@ -59,11 +64,10 @@
default = 0.75,
type = float)
args.add_argument("--noroc",
- action = 'store_false',
+ action = 'store_true',
help = "No ROC")
args.add_argument("--key",
help = "ROC api key",
- required = True,
type = str)
args.add_argument("--mbrlow",
help = "Low range of MBR",
@@ -82,5 +86,9 @@
if __name__ == '__main__':
+ log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.DEBUG, stream=sys.stdout)
+ log.debug("Starting person detection app")
args = build_argparser().parse_args()
+ if not args.noroc:
+ roc.set_mbr(args.key, args.devicegroup, args.mbrlow)
app.run(host='0.0.0.0', debug=True)