Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions static/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

15 changes: 15 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Upload Video</title>
</head>
<body style="font-family: Arial, sans-serif; margin: 0; padding: 0;">
<div style="background-color: #f2f2f2; padding: 20px;">
<h1 style="text-align: center;">CS 4279: License Plate Recognition From A Video Stream</h1>
<form action="/" method="POST" enctype="multipart/form-data" style="display: flex; justify-content: center; align-items: center;">
<input type="file" name="video" style="padding: 10px;">
<button type="submit" class="btn" style="margin-left: 10px; padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer;">Upload</button>
</form>
</div>
</body>
</html>
51 changes: 51 additions & 0 deletions templates/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!doctype html>
<html>
<head>
<title>Detected License Plates</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.3/socket.io.js"></script>
<script src="//code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #f2f2f2;
}

h1 {
text-align: center;
margin-top: 50px;
margin-bottom: 50px;
}

#output {
font-size: 16px;
line-height: 1.5;
margin: 50px auto;
max-width: 800px;
padding: 20px;
background-color: #ffffff;
border: 1px solid #cccccc;
border-radius: 5px;
box-shadow: 0 0 10px #cccccc;
}

#output span {
color: red;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('output', function(msg) {
$('#output').append(msg.data + '<br>');
});
socket.on('error', function(msg) {
$('#output').append('<span style="color:red">' + msg.message + '</span><br>');
});
});
</script>
</head>
<body>
<h1>Detected License Plates</h1>
<div id="output"></div>
</body>
</html>