-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
138 lines (100 loc) · 3.05 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from flask import Flask, render_template, Response,request
from camera import VideoCamera, VideoCamera2
import math
app = Flask(__name__)
mcnt = -1
mcnt2 = -1
side1 ='left'
side2 = 'right'
etcount = 0;
@app.route('/')
def index():
return render_template('index.html')
def gen(camera):
count =0
while True:
frame,etcount,sid1 = camera.get_frame(count)
# # save frame as JPEG filea
#atime.sleep(0.1)
count += 1
global mcnt
print("count 1 = " , mcnt)
global side1
if(etcount!=0):
mcnt = etcount
side1 = sid1
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
def gen2(camera):
count =0
while True:
frame,etcount,sid2 = camera.get_frame(count)
# # save frame as JPEG filea
#atime.sleep(0.1)
count += 1
global mcnt2
global side2
print("count2 = ", mcnt2)
if(etcount!=0):
mcnt2 = etcount
side2 = sid2
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.route('/video_feed')
def video_feed():
#os.system('python cameratest.py')
return Response(gen(VideoCamera()),mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/video_feed2')
def video_feed2():
#os.system('python cameratest.py')
return Response(gen2(VideoCamera2()),mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/answer')
def answer():
return render_template("test12.html",text=str(etcount))
@app.route('/answer2')
def answer2():
return render_template("test122.html",text=str(etcount))
@app.route('/suggestions')
def suggestions():
text = request.args.get('jsdata')
suggestions_list = []
global mcnt
global side1
str1 = str(abs(math.ceil(mcnt)))
suggestions_list.append(str1)
suggestions_list.append(side1)
return render_template('suggestions.html', suggestions=suggestions_list)
@app.route('/suggestions2')
def suggestions2():
text = request.args.get('jsdata')
suggestions_list = []
global mcnt2
global side2
str1 = str(abs(math.ceil(mcnt2)))
suggestions_list.append(str1)
suggestions_list.append(side2)
return render_template('suggestions.html', suggestions=suggestions_list)
@app.route('/s1')
def s1():
text = request.args.get('jsdata')
suggestions_list = []
global side1
if side1 == "left" :
str2 = "0"
else:
str2 = "1"
suggestions_list.append(str2)
return render_template('suggestions.html', suggestions=suggestions_list)
@app.route('/s2')
def s2():
text = request.args.get('jsdata')
suggestions_list = []
global side2
if side2 == "left" :
str2 = "0"
else:
str2 = "1"
suggestions_list.append(str2)
return render_template('suggestions.html', suggestions=suggestions_list)
if __name__ == '__main__':
app.run(debug=True)