-
Notifications
You must be signed in to change notification settings - Fork 0
/
Feedback.py
348 lines (242 loc) · 29.9 KB
/
Feedback.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/usr/bin/env python
# coding: utf-8
import Assist as AS
import detection as de
import Angles as ag
import cv2
def feedback(frame,angles,idx, level,EXS,EXSType_show,EXS_feedback,state_fed,tts_g,rec1,rec2):
cntr=[]
x=ag.dataset_angles(AS.Assist (level,EXS,EXSType_show[idx]))
global s_g
if EXS == "Biceps" :
if(EXSType_show[idx]== "Biceps Beg"):
if(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
EXS_feedback[idx]=" Now Bring your,hands up!"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)):
EXS_feedback[idx]=" Very Good ,Bring your ,hands down!"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
if angles[1] > int(x[2]+20) :
EXS_feedback[idx]="Bring your right, elbow close to ,your body"
elif angles[1] < int(x[2]-20):
EXS_feedback[idx]="Keep your right, elbow away from ,your body a ,little"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your left, elbow close to, your body"
elif angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your left, elbow away from, your body a, little"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[1] > int(x[2]+20) and angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your elbows, close to your, body"
elif angles[1] < int(x[2]-20) and angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your elbows, away from your, body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (not(angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20))) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)):
if angles[1] > int(x[3]+20) :
EXS_feedback[idx]="Bring your right, elbow close to, your body"
elif angles[1] < int(x[3]-20):
EXS_feedback[idx]="Keep your right, elbow away from ,your body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (not(angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20))):
if angles[5] > int(x[11]+20) :
EXS_feedback[idx]="Bring your left, elbow close to, your body"
elif angles[5] < int(x[11]-20):
EXS_feedback[idx]="Keep your left ,elbow away from ,your body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (not(angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20))) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (not(angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20))):
if angles[1] > int(x[3]+20) and angles[5] > int(x[11]+20):
EXS_feedback[idx]="Bring your elbows, close to your ,body"
elif angles[1] < int(x[3]-20)and angles[5] < int(x[11]-20):
EXS_feedback[idx]="Keep your elbows ,away from your ,body a little"
if (EXSType_show[idx] == "Biceps Int"):
if (angles[1] > x[2]+20 ):
EXS_feedback[idx]="Bring your right elbow close to your body"
elif (angles[1] < x[2]-20 ):
EXS_feedback[idx]="move your right elbow slightly away from your body"
elif(angles[0] <= int(x[0]+10) and angles[0] >= int(x[0]-10))and (angles[1] >= int(x[2]-10) and angles[1] <= int(x[2]+10)) and (angles[4] <= int(x[8]+10) and angles[4] >= int(x[8]-10)) and (angles[5] >= int(x[10]-10) and angles[5] <= int(x[10]+10)) :
EXS_feedback[idx]=" Very Good , go Up !"
elif(angles[0] <= int(x[1]+10) and angles[0] >= int(x[1]-10))and (angles[1] <= int(x[3]+10) and angles[1] >= int(x[3]-10)) and (angles[4] <= int(x[9]+10) and angles[4] >= int(x[9]-10))and (angles[5] <= int(x[11]+10) and angles[5] >= int(x[11]-10)):
EXS_feedback[idx]=" Go Down !"
if EXSType_show[idx] == "Biceps Adv" :
if(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
EXS_feedback[idx]=" Now Bring your hands up!"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)):
EXS_feedback[idx]=" Very Good ,Bring your hands down!"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
if angles[1] > int(x[2]+20) :
EXS_feedback[idx]="Bring your right elbow close to your body"
elif angles[1] < int(x[2]-20):
EXS_feedback[idx]="Keep your right elbow away from your body a little"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your left elbow close to your body"
elif angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your left elbow away from your body a little"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[1] > int(x[2]+20) and angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your elbows close to your body"
elif angles[1] < int(x[2]-20) and angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your elbows away from your body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (not(angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20))) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)):
if angles[1] > int(x[3]+20) :
EXS_feedback[idx]="Bring your right elbow close to your body"
elif angles[1] < int(x[3]-20):
EXS_feedback[idx]="Keep your right elbow away from your body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (not(angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20))):
if angles[5] > int(x[11]+20) :
EXS_feedback[idx]="Bring your left elbow close to your body"
elif angles[5] < int(x[11]-20):
EXS_feedback[idx]="Keep your left elbow away from your body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (not(angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20))) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (not(angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20))):
if angles[1] > int(x[3]+20) and angles[5] > int(x[11]+20):
EXS_feedback[idx]="Bring your elbows close to your body"
elif angles[1] < int(x[3]-20)and angles[5] < int(x[11]-20):
EXS_feedback[idx]="Keep your elbows away from your body a little"
if EXS == "Shoulder" :
if(EXSType_show[idx]== "Elbow Beg"):
if(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
EXS_feedback[idx]="very good ! ,try to Make ,your arms straight"
state_fed[idx] = "Down"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)) :
EXS_feedback[idx]="now!Go down, and make your,both hand at,the same line"
state_fed[idx] = "UP"
elif (angles[0] > int(x[0]+20)) and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
EXS_feedback[idx]="bring your right,elbow up"
elif angles[4] > int(x[8]+20) and (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))):
EXS_feedback[idx]="bring your left,elbow up"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
if angles[1] > int(x[2]+20) :
EXS_feedback[idx]="Bring your right,elbow close to,your body"
elif angles[1] < int(x[2]-20):
EXS_feedback[idx]="Keep your right,elbow away from,your body a,little"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your left,elbow close to,your body"
elif angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your left,elbow away from,your body a little"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[1] > int(x[2]+20) and angles[5] > int(x[10]+20) :
EXS_feedback[idx]="bring your elbows,close to your,body"
elif angles[1] < int(x[2]-20) and angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your elbows,away from your, bodya little"
elif(not(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20)))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)) :
if angles[0] > int(x[1]+20):
EXS_feedback[idx]="Bend your right,arm slightly"
elif angles[0] < int(x[1]-20):
EXS_feedback[idx]="make your right,arm straight,slightly"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (not(angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)) :
if angles[4] > int(x[9]+20):
EXS_feedback[idx]="Bend your left,arm slightly"
elif angles[4] < int(x[9]-20):
EXS_feedback[idx]="make your left,arm straight,slightly"
elif(not(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20)))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (not(angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)) :
if angles[4] > int(x[9]+20) and angles[0] > int(x[1]+20):
EXS_feedback[idx]="Bend your two ,arms slightly"
if angles[4] < int(x[9]-20) and angles[0] < int(x[1]-20):
EXS_feedback[idx]="Make your two ,arms straight,slightly"
if(EXSType_show[idx]== "Elbow Int"):
if(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
EXS_feedback[idx]=" Very Good , go Up !"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)):
EXS_feedback[idx]=" Now , go Down !"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) :
if angles[1] > int(x[2]+20) :
EXS_feedback[idx]="Bring your right elbow close to your body"
elif angles[1] < int(x[2]-20):
EXS_feedback[idx]="Keep your right elbow away from your body a little"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your left elbow close to your body"
elif angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your left elbow away from your body a little"
elif(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[4] <= int(x[8]+20) and angles[4] >= int(x[8]-20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) :
if angles[1] > int(x[2]+20) and angles[5] > int(x[10]+20) :
EXS_feedback[idx]="Bring your elbows close to your body"
elif angles[1] < int(x[2]-20) and angles[5] < int(x[10]-20):
EXS_feedback[idx]="Keep your elbows away from your body a little"
elif(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))and (not(angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20))) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))and (not(angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20))):
if angles[1] > int(x[3]+20) and angles[5] > int(x[11]+20) :
EXS_feedback[idx]="Keep your two elbows apart "
elif angles[1] < int(x[3]-20) and angles[5] < int(x[11]-20):
EXS_feedback[idx]="try to Make your arms straight "
elif(not(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20)))and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (not(angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)))and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)):
if angles[0] < int(x[1]-20) and angles[4] < int(x[9]-20):
EXS_feedback[idx]="try to make your arms straight "
if EXS == "Quad" :
if(EXSType_show[idx]== "Split Squat Contralateral Load"):
if (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
EXS_feedback[idx]=" Now , go Up !"
elif (angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20) ) and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[2] <= int(x[5]+20) and angles[2] >= int(x[5]-20)) and (angles[3] <= int(x[7]+20) and angles[3] >= int(x[7]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)) and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20) )and (angles[6] <= int(x[13]+20) and angles[6] >= int(x[13]-20)) and (angles[7] <= int(x[15]+20) and angles[7] >= int(x[15]-20)):
EXS_feedback[idx]="Right, Go Down !"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (not(angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20))) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
if angles[3] > int(x[6]+20):
EXS_feedback[idx]=" try to bend your right knee slightly!"
elif angles[3] < int(x[6]-20):
EXS_feedback[idx]=" try to make your right knee at a90-degree angle!"
elif (angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20) ) and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[2] <= int(x[5]+20) and angles[2] >= int(x[5]-20)) and (angles[3] <= int(x[7]+20) and angles[3] >= int(x[7]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)) and (not(angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20)))and (angles[6] <= int(x[13]+20) and angles[6] >= int(x[13]-20)) and (angles[7] <= int(x[15]+20) and angles[7] >= int(x[15]-20)):
if angles[5] > int(x[11]+20):
EXS_feedback[idx]=" Bring your left elbow close to your body!"
if angles[5] < int(x[11]-20):
EXS_feedback[idx]=" Keep your left elbow away from your body a little"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (not(angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20))) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
if angles[5] > int(x[10]+20):
EXS_feedback[idx]=" Bring your left elbow close to your body!"
if angles[5] < int(x[10]-20):
EXS_feedback[idx]=" Keep your left elbow away from your body a little"
if EXSType_show[idx] == "Dumbbell Reverse Lunge Intermediate":
if (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
EXS_feedback[idx]=" Very Good , go Up !"
elif (angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20) ) and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[2] <= int(x[5]+20) and angles[2] >= int(x[5]-20)) and (angles[3] <= int(x[7]+20) and angles[3] >= int(x[7]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)) and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20) )and (angles[6] <= int(x[13]+20) and angles[6] >= int(x[13]-20)) and (angles[7] <= int(x[15]+20) and angles[7] >= int(x[15]-20)):
EXS_feedback[idx]=" Go Down , Try to make your arms straight!"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (not(angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20))):
if angles[7] > int(x[14]+20):
EXS_feedback[idx]=" try to bend your left knee slightly!"
elif angles[7] < int(x[14]-20):
EXS_feedback[idx]=" try to make your left knee at a90-degree angle!"
elif (not(angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20))) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
if angles[0] < int(x[0]-20):
EXS_feedback[idx]=" Try to make your right arm straight!"
elif (not(angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20))) and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[2] <= int(x[5]+20) and angles[2] >= int(x[5]-20)) and (angles[3] <= int(x[7]+20) and angles[3] >= int(x[7]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)) and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20) )and (angles[6] <= int(x[13]+20) and angles[6] >= int(x[13]-20)) and (angles[7] <= int(x[15]+20) and angles[7] >= int(x[15]-20)):
if angles[0] < int(x[1]-20):
EXS_feedback[idx]=" Try to make your right arm straight!"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20)) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (not(angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20))) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
if angles[4] < int(x[8]-20):
EXS_feedback[idx]=" Try to make your left arm straight!"
elif (angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20) ) and (angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20)) and (angles[2] <= int(x[5]+20) and angles[2] >= int(x[5]-20)) and (angles[3] <= int(x[7]+20) and angles[3] >= int(x[7]-20)) and (not(angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20))) and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20) )and (angles[6] <= int(x[13]+20) and angles[6] >= int(x[13]-20)) and (angles[7] <= int(x[15]+20) and angles[7] >= int(x[15]-20)):
if angles[4] < int(x[9]-20):
EXS_feedback[idx]=" Try to make your left arm straight!"
elif (angles[0] <= int(x[1]+20) and angles[0] >= int(x[1]-20) ) and (not(angles[1] <= int(x[3]+20) and angles[1] >= int(x[3]-20))) and (angles[2] <= int(x[5]+20) and angles[2] >= int(x[5]-20)) and (angles[3] <= int(x[7]+20) and angles[3] >= int(x[7]-20)) and (angles[4] <= int(x[9]+20) and angles[4] >= int(x[9]-20)) and (angles[5] <= int(x[11]+20) and angles[5] >= int(x[11]-20) )and (angles[6] <= int(x[13]+20) and angles[6] >= int(x[13]-20)) and (angles[7] <= int(x[15]+20) and angles[7] >= int(x[15]-20)):
if angles[1] > int(x[3]+20):
EXS_feedback[idx]=" Bring your right elbow close to your body!"
elif (angles[0] <= int(x[0]+20) and angles[0] >= int(x[0]-20)) and (not(angles[1] >= int(x[2]-20) and angles[1] <= int(x[2]+20))) and (angles[2] >= int(x[4]-20) and angles[2] <= int(x[4]+20)) and (angles[3] >= int(x[6]-20) and angles[3] <= int(x[6]+20)) and (angles[4] >= int(x[8]-20) and angles[4] <= int(x[8]+20)) and (angles[5] >= int(x[10]-20) and angles[5] <= int(x[10]+20)) and (angles[6] >= int(x[12]-20) and angles[6] <= int(x[12]+20)) and (angles[7] >= int(x[14]-20) and angles[7] <= int(x[14]+20)):
if angles[1] > int(x[2]+20):
EXS_feedback[idx]=" Bring your right elbow close to your body!"
if(EXSType_show[idx]== "Prisoner Squat"):
if angles[0] <= int(x[0]+40) and angles[1] <= int(x[2]+40) and angles[1] >=100 and angles[2] <= int(x[4]+40) and angles[3] <= int(x[6]+40) and angles[4] <= int(x[8]+40) and angles[5] <= int(x[10]+40) and angles[5] >=100 and angles[6] <= int(x[12]+40) and angles[7] <= int(x[14]+40) :
EXS_feedback[idx]=" Very Good , go Up !"
if angles[0] >= int(x[1]-40) and angles[1] >= int(x[3]-40) and angles[1] >=100 and angles[2] >= int(x[5]-40) and angles[3] >= int(x[7]-40) and angles[4] >= int(x[9]-40) and angles[5] >= int(x[11]-40) and angles[5] >=100 and angles[6] >= int(x[13]-40) and angles[7] >= int(x[15]-40) :
EXS_feedback[idx]=" Go Down !"
if(EXS=="Hamstring"):
if(EXSType_show[idx]== "Kettlebell Swing"):
if angles[0] <= int(x[0]+10):
EXS_feedback[idx]="straight your right arm"
elif angles[4] <= int(x[8]+10):
EXS_feedback[idx]="straight your right arm"
elif (angles[1] >= int(x[2]-30) and angles[1] <= int(x[2]+30)) and (angles[2] < int(x[4]-30) or angles[6] < int(x[12]-30)) and (angles[3] >= int(x[6]-30) and angles[3] <= int(x[6]+30)) and (angles[5] >= int(x[10]-30) and angles[5] <= int(x[10]+30)) and (angles[6] >= int(x[12]-30) and angles[6] <= int(x[12]+30)) and (angles[7] >= int(x[14]-30) and angles[7] <= int(x[14]+30)):
EXS_feedback[idx]="straight your back"
elif (angles[1] >= int(x[2]-30) and angles[1] <= int(x[2]+30)) and angles[3] < int(x[6]-30) and (angles[5] >= int(x[10]-30) and angles[5] <= int(x[10]+30)) and (angles[7] >= int(x[14]-30) and angles[7] <= int(x[14]+30)):
EXS_feedback[idx]="straight your right leg"
elif (angles[1] >= int(x[2]-30) and angles[1] <= int(x[2]+30)) and (angles[5] >= int(x[10]-30) and angles[5] <= int(x[10]+30)) and angles[7] < int(x[14]-30):
EXS_feedback[idx]="straight your left leg"
#Determine the type of feedback(audio / text)
if EXS_feedback[idx] != None :
if(tts_g !=2):
tts_g.SetVolume(50)
s=str(idx)+" "+str(EXS_feedback[idx])
try:
if s_g != s:
tts_g.Speak(s,1)
s_g = s
except NameError:s_g=""
else:
if len(rec1) !=0:
rect = cv2.rectangle(frame,(int(rec1[0]-60),int(rec1[1]-150)), (int(rec2[0]+110),int(rec2[1]-150)),(105,105,105),-1)
text =str(EXS_feedback[idx])
for i, line in enumerate(text.split(',')):
cv2.putText(rect,line, (int(rec1[0]-50),int(rec1[1]-135+i*17)), cv2.LINE_AA , .7, (255,255,255), 1,cv2.LINE_AA )