diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14db69a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +server/__pycache__/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdac573 --- /dev/null +++ b/README.md @@ -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//info returns client information as json + /cam/ returns camera list as json + /cam//stream returns a unedited mjpeg stream + /cam//processed returns a mjpeg stream with persons highlighted + /info returns camera infromation + + +### Architektur + +![Architektur Übersicht](arch.png) \ No newline at end of file diff --git a/arch.png b/arch.png new file mode 100644 index 0000000..b9278f1 Binary files /dev/null and b/arch.png differ diff --git a/mock/Dockerfile b/mock/Dockerfile deleted file mode 100644 index c2dc85b..0000000 --- a/mock/Dockerfile +++ /dev/null @@ -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"] \ No newline at end of file diff --git a/mock/app.py b/mock/app.py deleted file mode 100644 index 6eb1517..0000000 --- a/mock/app.py +++ /dev/null @@ -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//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//info') -def cam_info(num): - json = cams[int(num)] - return jsonify(json) - -@application.route('/cam//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) diff --git a/mock/cams.json b/mock/cams.json deleted file mode 100644 index 104847d..0000000 --- a/mock/cams.json +++ /dev/null @@ -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 - } -] \ No newline at end of file diff --git a/mock/clients.json b/mock/clients.json deleted file mode 100644 index d819984..0000000 --- a/mock/clients.json +++ /dev/null @@ -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 - } -] \ No newline at end of file diff --git a/mock/requirements.txt b/mock/requirements.txt deleted file mode 100644 index e3806c4..0000000 --- a/mock/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -requests -flask -gunicorn -opencv-python \ No newline at end of file