From 7f9cf62aa3de34f75492a56feefa3ee4c586c6c9 Mon Sep 17 00:00:00 2001 From: Udit Malik <51827904+malikudit@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:45:44 -0500 Subject: [PATCH 1/4] Adds a Flask interface A simple Flask wrapper for running DarkPlate. Allows user to upload videos from a UI, and see license plate recognition results in real-time. --- app.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..bdabf7b --- /dev/null +++ b/app.py @@ -0,0 +1,46 @@ + +from flask import Flask, render_template, request, redirect, url_for +from flask_socketio import SocketIO, emit +import subprocess +import os +import threading + +app = Flask(__name__) +app.config['SECRET_KEY'] = '324jjksdn34nn2j3kkv3' +socketio = SocketIO(app) + + +@app.route('/', methods=['GET', 'POST']) +def index(): + global hello + if request.method == 'POST': + video = request.files['video'] + video.save('static/' + video.filename) + hello = 'static/' + video.filename + return redirect(url_for('output', hello=hello)) + return render_template('index.html') + +def run_process(): + process = subprocess.Popen(["build/src/DarkPlate", hello], stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, text=True) + while True: + out = process.stdout.readline() + if out == '' and process.poll() is not None: + break + if out: + socketio.emit('output', {'data': out.strip()}) + + +@app.route('/output') +def output(): + return render_template('output.html') + + +@socketio.on('connect') +def test_connect(): + print('Client connected') + thread = threading.Thread(target=run_process) + thread.start() + +if __name__ == '__main__': + socketio.run(app) From 986f65b3b13829e1cc668b7309bf0a0bcf111541 Mon Sep 17 00:00:00 2001 From: Udit Malik <51827904+malikudit@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:50:29 -0500 Subject: [PATCH 2/4] Create README.md --- static/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 static/README.md diff --git a/static/README.md b/static/README.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/static/README.md @@ -0,0 +1 @@ + From 0863e8c1cf560d3c78191a1142599958d599d8d7 Mon Sep 17 00:00:00 2001 From: Udit Malik <51827904+malikudit@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:50:53 -0500 Subject: [PATCH 3/4] Create index.html --- templates/index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 templates/index.html diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..5afa342 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,15 @@ + + +
+