Skip to content
Snippets Groups Projects
Commit 7041b274 authored by Vajay Mónika's avatar Vajay Mónika
Browse files

smoother scrolling and moving

parent 7bb4bc58
Branches
No related tags found
No related merge requests found
......@@ -15,4 +15,7 @@ Megbeszélés 2024. 11. 31:
mozdulatok:
drag: nyitott tenyér -> drop sima cursor stop if előtte drag
Móni 2024. 11. 22.:
- egér mozgatás már nem szaggatott
\ No newline at end of file
......@@ -85,6 +85,7 @@ def main():
mouse.add_prediction(mouse_command)
if mouse_command == "move cursor" or "grab":
mouse.get_hand_pos(landmark_list[8])
# transform back RGB and show frame with annotation
frame_annotated = cv2.cvtColor(frameRGB, cv2.COLOR_RGB2BGR)
cv2.imshow('Hand tracking', frame_annotated)
......
......@@ -14,7 +14,7 @@ class Mouse:
self.freeze_action = False
# parameters to fine-tune
self.action_length = 5
self.action_length = 15
#self.move_distance = 10
self.scroll_distance = 50
#self.time_checking = 0.5
......@@ -28,6 +28,13 @@ class Mouse:
self.predictions.append(prediction)
if len(self.predictions) == self.action_length:
self.make_action()
elif self.previous_action in {"move cursor", "scrolling up", "scrolling down", "scrolling left", "scrolling right"}:
if len(self.predictions) > 3:
safe_action = self.get_major_element(self.predictions[-3:])
if safe_action == self.previous_action:
self.mouse_control(self.previous_action)
else:
self.mouse_control(self.previous_action)
def make_action(self):
action = self.get_major_element(self.predictions)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment