-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
69 lines (54 loc) · 1.47 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import main, ocrTesseract
from flask import Flask, render_template, Response,jsonify
from camera import VideoCamera
from ImageLoader import ImageLoader
import camera
import time
frame = None
play = True
def gen(camera,callback):
global frame,play;
while True:
if play:
frame = camera.get_frame(callback)
else:
time.sleep(1)
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/pause')
def pause():
global play
play = False;
return 'Paused';
@app.route('/play')
def play():
global play
play = True;
return 'Playing';
@app.route('/stream')
def stream():
return render_template('stream.html')
@app.route('/cullp')
def cullp():
return jsonify({'data': render_template('culprit.html', culprits = main.getCulprits())});
@app.route('/compare')
def compare():
return render_template('compare.html')
@app.route('/ocr')
def ocr():
return render_template('ocr.html')
@app.route('/nextimage/<index>')
def nextimage(index):
data = imloader.next(index);
return data;
cam = VideoCamera(main.videopath)
imloader = ImageLoader('./static/Saved')
@app.route('/video_feed')
def video_feed():
global play,cam
return Response(gen(cam,main.process),mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)