Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f9fb5d

Browse files
added vis threshold + feedback
1 parent 20406f8 commit 9f9fb5d

File tree

1 file changed

+51
-9
lines changed

1 file changed

+51
-9
lines changed

Prototype_2_Electric_Boogalooo.ipynb

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"colab": {
66
"provenance": [],
77
"mount_file_id": "1YJfEK8zha4PfUk2yP9y-XbO4vtmn83gE",
8-
"authorship_tag": "ABX9TyP54LxKBJts0KXl7EfJYOpo",
8+
"authorship_tag": "ABX9TyPkTtXM08RbtO4T0HwiFsGT",
99
"include_colab_link": true
1010
},
1111
"kernelspec": {
@@ -151,6 +151,7 @@
151151
" self.right_heel = pll[30]\n",
152152
" self.left_foot_index = pll[31]\n",
153153
" self.right_foot_index = pll[32]\n",
154+
" self.threshold = 66\n",
154155
"\n",
155156
" # Returns the angle formed by any three points, with pointb as the center\n",
156157
" def angle(self, pointa, pointb, pointc):\n",
@@ -180,62 +181,103 @@
180181
" # Then figure out what angle you need to calculate\n",
181182
" # Arm, Grip, Back, Arms by Side, Leg, Hip Angle, Calf\n",
182183
" if row[0] == 'Arm':\n",
183-
" if ((self.right_shoulder.visibility + self.right_elbow.visibility + self.right_wrist.visibility) / 3) > ((self.left_shoulder.visibility + self.left_elbow.visibility + self.left_wrist.visibility) / 3): # Finds the better side and uses that for angles\n",
184+
" right_vis = (self.right_shoulder.visibility + self.right_elbow.visibility + self.right_wrist.visibility) / 3\n",
185+
" left_vis = (self.left_shoulder.visibility + self.left_elbow.visibility + self.left_wrist.visibility) / 3\n",
186+
" if right_vis > left_vis: # Finds the better side and uses that for angles\n",
187+
" if right_vis < self.threshold:\n",
188+
" return \"Right Arm Isn't Visible\"\n",
184189
" working_angle = self.angle(self.right_shoulder, self.right_elbow, self.right_wrist)\n",
185190
" else:\n",
191+
" if left_vis < self.threshold:\n",
192+
" return \"Left Arm Isn't Visible\"\n",
186193
" working_angle = self.angle(self.left_shoulder, self.left_elbow, self.left_wrist)\n",
187-
" print(working_angle)\n",
194+
"\n",
188195
" if working_angle < int(row[1]): # See if the angle is within bounds\n",
189196
" return \"Try Straightening Your Arm Somewhat\"\n",
190197
" if working_angle > int(row[2]):\n",
191198
" return \"Try Bending Your Elbow More\"\n",
192199
"\n",
193200
" elif row[0] == 'Wrist Angle':\n",
194-
" if ((self.right_elbow.visibility + self.right_wrist.visibility + self.right_thumb.visibility) / 3) > ((self.left_elbow.visibility + self.left_wrist.visibility + self.left_thumb.visibility) / 3):\n",
201+
" right_vis = (self.right_elbow.visibility + self.right_wrist.visibility + self.right_thumb.visibility) / 3\n",
202+
" left_vis = (self.left_elbow.visibility + self.left_wrist.visibility + self.left_thumb.visibility) / 3\n",
203+
" if right_vis > left_vis:\n",
204+
" if right_vis < self.threshold:\n",
205+
" return \"Right Wrist Isn't Visible\"\n",
195206
" working_angle = self.angle(self.right_elbow, self.right_wrist, self.right_thumb)\n",
196207
" else:\n",
208+
" if left_vis < self.threshold:\n",
209+
" return \"Left Wrist Isn't Visible\"\n",
197210
" working_angle = self.angle(self.left_elbow, self.left_wrist, self.left_thumb)\n",
211+
"\n",
198212
" if working_angle < int(row[1]):\n",
199213
" return \"Try Straightening Your Wrist Somewhat\"\n",
200214
" if working_angle > int(row[2]):\n",
201215
" return \"Try Bending Your Wrist More\"\n",
202216
"\n",
203217
"\n",
204218
" elif row[0] == 'Hip Angle':\n",
205-
" if ((self.right_shoulder.visibility + self.right_hip.visibility + self.right_knee.visibility) / 3) > ((self.left_shoulder.visibility + self.left_hip.visibility + self.left_knee.visibility) / 3):\n",
219+
" right_vis = (self.right_shoulder.visibility + self.right_hip.visibility + self.right_knee.visibility) / 3\n",
220+
" left_vis = (self.left_shoulder.visibility + self.left_hip.visibility + self.left_knee.visibility) / 3\n",
221+
" if right_vis > left_vis:\n",
222+
" if right_vis < self.threshold:\n",
223+
" return \"Right Side of Body Isn't Visible\"\n",
206224
" working_angle = self.angle(self.right_shoulder, self.right_hip, self.right_knee)\n",
207225
" else:\n",
226+
" if left_vis < self.threshold:\n",
227+
" return \"Left Side of Body Isn't Visible\"\n",
208228
" working_angle = self.angle(self.left_shoulder, self.left_hip, self.left_knee)\n",
229+
"\n",
209230
" if working_angle < int(row[1]):\n",
210231
" return \"Try Straightening Your Hip Somewhat\"\n",
211232
" if working_angle > int(row[2]):\n",
212233
" return \"Try Bending Over More\"\n",
213234
"\n",
214235
" elif row[0] == 'Arms by Side':\n",
215-
" if ((self.right_elbow.visibility + self.right_shoulder.visibility + self.right_hip.visibility) / 3) > ((self.left_elbow.visibility + self.left_shoulder.visibility + self.left_hip.visibility) / 3):\n",
236+
" right_vis = (self.right_elbow.visibility + self.right_shoulder.visibility + self.right_hip.visibility) / 3\n",
237+
" left_vis = (self.left_elbow.visibility + self.left_shoulder.visibility + self.left_hip.visibility) / 3\n",
238+
" if right_vis > left_vis:\n",
239+
" if right_vis < self.threshold:\n",
240+
" return \"Right Arm and Hip Isn't Visible\"\n",
216241
" working_angle = self.angle(self.right_elbow, self.right_shoulder, self.right_hip)\n",
217242
" else:\n",
243+
" if left_vis < self.threshold:\n",
244+
" return \"Left Arm and Hip Isn't Visible\"\n",
218245
" working_angle = self.angle(self.left_elbow, self.left_shoulder, self.left_hip)\n",
246+
"\n",
219247
" if working_angle < int(row[1]):\n",
220248
" return \"Try Spreading Your Arms Out More\"\n",
221249
" if working_angle > int(row[2]):\n",
222250
" return \"Try Bringing Your Arms Somewhat Closer To Your Body\"\n",
223251
"\n",
224252
" elif row[0] == 'Leg':\n",
225-
" if ((self.right_hip.visibility + self.right_knee.visibility + self.right_ankle.visibility) / 3) > ((self.left_hip.visibility + self.left_knee.visibility + self.left_ankle.visibility) / 3):\n",
253+
" right_vis = (self.right_hip.visibility + self.right_knee.visibility + self.right_ankle.visibility) / 3\n",
254+
" left_vis = (self.left_hip.visibility + self.left_knee.visibility + self.left_ankle.visibility) / 3\n",
255+
" if right_vis > left_vis:\n",
256+
" if right_vis < self.threshold:\n",
257+
" return \"Right Leg Isn't Visible\"\n",
226258
" working_angle = self.angle(self.right_hip, self.right_knee, self.right_ankle)\n",
227259
" else:\n",
260+
" if left_vis < self.threshold:\n",
261+
" return \"Left Leg Isn't Visible\"\n",
228262
" working_angle = self.angle(self.left_hip, self.left_knee, self.left_ankle)\n",
263+
"\n",
229264
" if working_angle < int(row[1]):\n",
230265
" return \"Try Straightening Your Legs More\"\n",
231266
" if working_angle > int(row[2]):\n",
232267
" return \"Try Bending Your Legs More\"\n",
233268
"\n",
234269
" elif row[0] == 'Calf':\n",
235-
" if ((self.right_ankle.visibility + self.right_heel.visibility + self.right_foot_index.visibility) / 3) > ((self.left_ankle.visibility + self.left_heel.visibility + self.left_foot_index.visibility) / 3):\n",
270+
" right_vis = (self.right_ankle.visibility + self.right_heel.visibility + self.right_foot_index.visibility) / 3\n",
271+
" left_vis = (self.left_ankle.visibility + self.left_heel.visibility + self.left_foot_index.visibility) / 3\n",
272+
" if right_vis > left_vis:\n",
273+
" if right_vis < self.threshold:\n",
274+
" return \"Right Foot Isn't Visible\"\n",
236275
" working_angle = self.angle(self.right_ankle, self.right_heel, self.right_foot_index)\n",
237276
" else:\n",
277+
" if left_vis < self.threshold:\n",
278+
" return \"Left Foot Isn't Visible\"\n",
238279
" working_angle = self.angle(self.left_ankle, self.left_heel, self.left_foot_index)\n",
280+
"\n",
239281
" if working_angle < int(row[1]):\n",
240282
" return \"Try Pointing Your Feet More (Tiptoe position)\"\n",
241283
" if working_angle > int(row[2]):\n",
@@ -246,7 +288,7 @@
246288
"metadata": {
247289
"id": "RHyJwan8acCz"
248290
},
249-
"execution_count": 9,
291+
"execution_count": 11,
250292
"outputs": []
251293
},
252294
{

0 commit comments

Comments
 (0)