Skip to content

Commit 247aa80

Browse files
committed
Update app.py
1 parent 0b1ab5c commit 247aa80

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def get_the_arguments():
3636
return arguments
3737

3838
def main():
39-
39+
40+
4041
arguments = get_the_arguments()
4142

4243
vid_d = arguments.device
@@ -358,6 +359,7 @@ def draw_landmarks(img, landmark_pts):
358359
cv.circle(img, (landmark[0], landmark[1]), 5, (255, 165, 0),
359360
-1)
360361
cv.circle(img, (landmark[0], landmark[1]), 5, (0, 128, 0), 1)
362+
361363
return img
362364

363365
def draw_bound_rect(enable_brect, img, bound_rectangle):
@@ -367,25 +369,26 @@ def draw_bound_rect(enable_brect, img, bound_rectangle):
367369
return img
368370

369371
def draw_information_txt(img, bound_rectangle, handedness, hand_sign_txt,
370-
finger_gesture_text):
372+
finger_gesture_text):
371373
cv.rectangle(img, (bound_rectangle[0], bound_rectangle[1]), (bound_rectangle[2], bound_rectangle[1] - 22),
372374
(0, 0, 0), -1)
373375

374-
information_text = handedness.classification [0].label[0:]
376+
information_text = handedness.classification[0].label[0:]
375377
if hand_sign_txt != "":
376378
information_text = information_text + ':' + hand_sign_txt
377379
cv.putText(img, information_text, (bound_rectangle[0] + 5, bound_rectangle[1] - 4),
378380
cv.FONT_HERSHEY_COMPLEX, 0.6, (255, 255, 255), 1, cv.LINE_AA)
379381

380-
if finger_gesture_text != "":
381-
cv.putText(img, "Gesture of finger->" + finger_gesture_text, (10, 60),
382+
if finger_gesture_text != "" and finger_gesture_text != "?":
383+
cv.putText(img, "Gesture of finger - " + finger_gesture_text, (10, 60),
382384
cv.FONT_HERSHEY_COMPLEX, 1.0, (0, 0, 0), 4, cv.LINE_AA)
383-
cv.putText(img, "Gesture of finger->" + finger_gesture_text, (10, 60),
385+
cv.putText(img, "Gesture of finger - " + finger_gesture_text, (10, 60),
384386
cv.FONT_HERSHEY_COMPLEX, 1.0, (255, 255, 255), 2,
385387
cv.LINE_AA)
386388

387389
return img
388390

391+
389392
def draw_pt_history(img, pt_history):
390393
for ind, point in enumerate(pt_history):
391394
if point[0] != 0 and point[1] != 0:
@@ -395,20 +398,21 @@ def draw_pt_history(img, pt_history):
395398
return img
396399

397400
def draw_information(img,fps_val, curr_mode, num):
398-
cv.putText(img, "Frames Per Second->" + str(fps_val), (10, 30), cv.FONT_HERSHEY_COMPLEX,
401+
cv.putText(img, "Frames Per Second - " + str(fps_val), (10, 30), cv.FONT_HERSHEY_COMPLEX,
399402
1.0, (0, 0, 0), 4, cv.LINE_AA)
400-
cv.putText(img, "Frames Per Second->" + str(fps_val), (10, 30), cv.FONT_HERSHEY_COMPLEX,
403+
cv.putText(img, "Frames Per Second - " + str(fps_val), (10, 30), cv.FONT_HERSHEY_COMPLEX,
401404
1.0, (255, 255, 255), 2, cv.LINE_AA)
402405
mode_string = ['Logging Key Point', 'Logging Point History']
403406
if 1 <= curr_mode <= 2:
404-
cv.putText(img, "Mode->" + mode_string[curr_mode - 1], (10, 90),
407+
cv.putText(img, "Mode - " + mode_string[curr_mode - 1], (10, 90),
405408
cv.FONT_HERSHEY_COMPLEX, 0.6, (255, 255, 255), 1,
406409
cv.LINE_AA)
407410
if 0 <= num <= 9:
408-
cv.putText(img, "Num->" + str(num), (10, 110),
411+
cv.putText(img, "Num - " + str(num), (10, 110),
409412
cv.FONT_HERSHEY_COMPLEX, 0.6, (255, 255, 255), 1,
410413
cv.LINE_AA)
411414
return img
412415

413416
if __name__ == '__main__':
414417
main()
418+

0 commit comments

Comments
 (0)