improved tracking, added red dot
This commit is contained in:
parent
6872124632
commit
def7acc30c
@ -14,7 +14,7 @@ class MyVideoCapture:
|
||||
self.mp_drawing = mp.solutions.drawing_utils
|
||||
self.mp_hands = mp.solutions.hands
|
||||
self.hands = self.mp_hands.Hands(
|
||||
min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
||||
min_detection_confidence=0.7, min_tracking_confidence=0.7)
|
||||
if not self.vid.isOpened():
|
||||
raise ValueError("Unable to open video source", 0)
|
||||
# Get video source width and height
|
||||
@ -42,7 +42,7 @@ class MyVideoCapture:
|
||||
fingers['index'] = sgest.check_index_finger(hand_landmarks)
|
||||
fingers['start_stop'] = sgest.get_start_stop(hand_landmarks)
|
||||
fingers['ninja'] = sgest.search_for_ninja_turtle(hand_landmarks)
|
||||
# fingers['middle'] = sgest.check_middle_finger(hand_landmarks)
|
||||
fingers['middle'] = sgest.check_middle_finger(hand_landmarks)
|
||||
# fingers['ring'] = sgest.check_ring_finger(hand_landmarks)
|
||||
# fingers['pinky'] = sgest.check_pinky_finger(hand_landmarks)
|
||||
else:
|
||||
|
@ -29,7 +29,7 @@ class ProjectView(tk.Frame, AbstractView):
|
||||
self.bottom_frame = None
|
||||
self.top_frame = None
|
||||
self.first_time = True
|
||||
self.flag_just_done = False
|
||||
self.other_gestures_flag_possible = False
|
||||
@staticmethod
|
||||
def get_view_name() -> str:
|
||||
return PROJECT_VIEW_NAME
|
||||
@ -85,13 +85,14 @@ class ProjectView(tk.Frame, AbstractView):
|
||||
fingers, frame, success = self.vid.get_frame()
|
||||
if fingers is not None:
|
||||
index_finger = fingers['index']
|
||||
middle_finger = fingers['middle']
|
||||
start_stop = fingers['start_stop']
|
||||
if fingers['ninja'] != 'nothing' and self.flag_just_done == False:
|
||||
if fingers['ninja'] != 'nothing' and self.other_gestures_flag_possible == True:
|
||||
#print('trying')
|
||||
self.create_window()
|
||||
|
||||
cv2.waitKey(10)
|
||||
self.flag_just_done = True
|
||||
self.other_gestures_flag_possible = False
|
||||
x = index_finger['x']
|
||||
y = index_finger['y']
|
||||
x, y = self.scale_points(x, y)
|
||||
@ -101,14 +102,31 @@ class ProjectView(tk.Frame, AbstractView):
|
||||
print('start')
|
||||
self.start_draw = True
|
||||
self.first_time = True
|
||||
self.flag_just_done = True
|
||||
self.other_gestures_flag_possible = False
|
||||
|
||||
elif start_stop == 'stop':
|
||||
print('stop')
|
||||
self.start_draw = False
|
||||
self.first_time = False
|
||||
self.flag_just_done = False
|
||||
if self.start_draw and index_finger['straight']:
|
||||
self.other_gestures_flag_possible = True
|
||||
|
||||
if self.start_draw and index_finger['straight'] and middle_finger['straight']:
|
||||
|
||||
x = index_finger['x']
|
||||
y = index_finger['y']
|
||||
x, y = self.scale_points(x, y)
|
||||
if self.first_time == True:
|
||||
self.previous_x = x
|
||||
self.previous_y = y
|
||||
self.first_time = False
|
||||
#print("first_time")
|
||||
canvas_id = self.canvas.create_line(x, y, x + 2, y + 2, self.previous_x, self.previous_y, tags='point', width=3, fill = 'red')
|
||||
self.canvas.after(100, self.canvas.delete, canvas_id)
|
||||
#self.canvas.create_line(x, y, x+1, y+1, self.previous_x, self.previous_y, tags='point', width=3)
|
||||
self.previous_x = x
|
||||
self.previous_y = y
|
||||
|
||||
if self.start_draw and index_finger['straight'] and not middle_finger['straight']:
|
||||
|
||||
x = index_finger['x']
|
||||
y = index_finger['y']
|
||||
@ -119,6 +137,7 @@ class ProjectView(tk.Frame, AbstractView):
|
||||
self.first_time = False
|
||||
#print("first_time")
|
||||
self.canvas.create_line(x, y, x+1, y+1, self.previous_x, self.previous_y, tags='point', width=3)
|
||||
|
||||
self.previous_x = x
|
||||
self.previous_y = y
|
||||
if success:
|
||||
|
Loading…
Reference in New Issue
Block a user