added docs
This commit is contained in:
parent
e8599e01ae
commit
28ff955a41
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
server/__pycache__/
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
# IoI Interaktion ohne Interaktion
|
||||||
|
##### (Demo)
|
||||||
|
|
||||||
|
Dieses Projekt enthält alle Komponenten eines Systems zu überwachung und Analyse mehrerer Videostreams und der Steuerung von Geräten auf Basis der Analyse.
|
||||||
|
|
||||||
|
### Struktur:
|
||||||
|
Pfad | Beschreibung
|
||||||
|
----|---
|
||||||
|
./FrontEnd/ | Enthält den Front-End Client. Geschrieben in C#.
|
||||||
|
./client/ | Ein simpler Flask (Python) Endpoint der als Demo Endpoint dient
|
||||||
|
./server/ | Enthält alle Dateien für Das Backend
|
||||||
|
./server/cams.json | Entält Informationen über die genutzen Videostreams, kann als Teil der Datenbank verstanden werden
|
||||||
|
./server/clients.json | Entält Informationen über die möglichen Endpoints, kann als Teil der Datenbank verstanden werden
|
||||||
|
./server/Dockerfile | Enthält die Deployment Beschreibung. Kann als Prod. Env genutzt werden. Nutzt in diesem Fall aber nur die CPU
|
||||||
|
./server/model.pb | Enthält das genutzte vortrainierte Neuronale Netz
|
||||||
|
./server/motion_detector_old.py | Ein erster Prototyp eines rein OpenCV basierten Ansatzes
|
||||||
|
./server/requirments.txt | Enthält die pip Abhängigkeiten, wird von Dockerfile genutzt
|
||||||
|
./server/detector.py | Stellt die detection API die vom Server genutzt wird. Hier wird das NN ausgeführt
|
||||||
|
./server/app.py | Ein Flask Server. Nutzt detector.py um Personen in Videos zu erkennen. Bietet mehrere Routen, mehr hierzu weiter unten.
|
||||||
|
|
||||||
|
### Routes
|
||||||
|
|
||||||
|
/client/ returns client list as json
|
||||||
|
/client/<num>/info returns client information as json
|
||||||
|
/cam/ returns camera list as json
|
||||||
|
/cam/<num>/stream returns a unedited mjpeg stream
|
||||||
|
/cam/<num>/processed returns a mjpeg stream with persons highlighted
|
||||||
|
/info returns camera infromation
|
||||||
|
|
||||||
|
|
||||||
|
### Architektur
|
||||||
|
|
||||||
|

|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
FROM python:3.7
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y gcc libevent-dev python-dev
|
|
||||||
|
|
||||||
COPY ./requirements.txt /
|
|
||||||
RUN pip install -r /requirements.txt
|
|
||||||
|
|
||||||
COPY ./ /app
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 5000
|
|
||||||
|
|
||||||
|
|
||||||
CMD ["gunicorn", "-b", "0.0.0.0:5000","--worker-class", "gthread", "-w","4", "--threads", "100", "app"]
|
|
||||||
66
mock/app.py
66
mock/app.py
|
|
@ -1,66 +0,0 @@
|
||||||
import os
|
|
||||||
import random
|
|
||||||
import json
|
|
||||||
from importlib import import_module
|
|
||||||
import cv2
|
|
||||||
from flask import Flask, jsonify, Response
|
|
||||||
|
|
||||||
application = Flask(__name__)
|
|
||||||
clients = []
|
|
||||||
cams = []
|
|
||||||
with open("./clients.json", 'r', encoding='utf-8') as f:
|
|
||||||
array = f.read()
|
|
||||||
clients = json.loads(array)
|
|
||||||
|
|
||||||
with open("./cams.json", 'r', encoding='utf-8') as f:
|
|
||||||
array = f.read()
|
|
||||||
cams = json.loads(array)
|
|
||||||
|
|
||||||
|
|
||||||
class VideoCamera(object):
|
|
||||||
def __init__(self, url):
|
|
||||||
self.video = cv2.VideoCapture(url)
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
self.video.release()
|
|
||||||
|
|
||||||
def get_frame(self):
|
|
||||||
success, image = self.video.read()
|
|
||||||
ret, jpeg = cv2.imencode('.jpg', image)
|
|
||||||
return jpeg.tobytes()
|
|
||||||
|
|
||||||
def gen(camera):
|
|
||||||
"""Video streaming generator function."""
|
|
||||||
while True:
|
|
||||||
frame = camera.get_frame()
|
|
||||||
yield (b'--frame\r\n'
|
|
||||||
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
|
|
||||||
|
|
||||||
@application.route('/client/')
|
|
||||||
def client_list():
|
|
||||||
json = clients
|
|
||||||
return jsonify(json)
|
|
||||||
|
|
||||||
@application.route('/client/<num>/info')
|
|
||||||
def client_info(num):
|
|
||||||
json = clients[int(num)]
|
|
||||||
return jsonify(json)
|
|
||||||
|
|
||||||
@application.route('/cam/')
|
|
||||||
def cam_list():
|
|
||||||
json = cams
|
|
||||||
return jsonify(json)
|
|
||||||
|
|
||||||
@application.route('/cam/<num>/info')
|
|
||||||
def cam_info(num):
|
|
||||||
json = cams[int(num)]
|
|
||||||
return jsonify(json)
|
|
||||||
|
|
||||||
@application.route('/cam/<num>/stream')
|
|
||||||
def cam_stream(num):
|
|
||||||
return Response(gen(VideoCamera(cams[int(num)]["ip"])),
|
|
||||||
mimetype='multipart/x-mixed-replace; boundary=frame')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print(clients[0])
|
|
||||||
application.run(host='127.0.0.1', port=80, threaded=True)
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": 0,
|
|
||||||
"label": "cam1",
|
|
||||||
"ip": "http://89.29.108.38:80/mjpg/video.mjpg",
|
|
||||||
"client_id": 0,
|
|
||||||
"status": true,
|
|
||||||
"x":0.2,
|
|
||||||
"y":0.8,
|
|
||||||
"angle": 130
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"label": "cam2",
|
|
||||||
"ip": "http://89.29.108.38:80/mjpg/video.mjpg",
|
|
||||||
"client_id": 1,
|
|
||||||
"status": false,
|
|
||||||
"x":0.4,
|
|
||||||
"y":0.2,
|
|
||||||
"angle": 190
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"label": "cam3",
|
|
||||||
"ip": "http://62.99.80.154:81/mjpg/video.mjpg",
|
|
||||||
"client_id": 2,
|
|
||||||
"status": true,
|
|
||||||
"x":0.9,
|
|
||||||
"y":0.1,
|
|
||||||
"angle": 270
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": 0,
|
|
||||||
"label": "name1",
|
|
||||||
"ip": "http://127.0.0.2",
|
|
||||||
"status": true,
|
|
||||||
"x":0.11,
|
|
||||||
"y":0.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"label": "name2",
|
|
||||||
"ip": "http://127.0.0.2",
|
|
||||||
"status": false,
|
|
||||||
"x":0.3,
|
|
||||||
"y":0.3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"label": "name3",
|
|
||||||
"ip": "http://127.0.0.2",
|
|
||||||
"status": true,
|
|
||||||
"x":0.5,
|
|
||||||
"y":0.6
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
requests
|
|
||||||
flask
|
|
||||||
gunicorn
|
|
||||||
opencv-python
|
|
||||||
Loading…
Reference in New Issue