diff --git a/developement.txt b/developement.txt index ba244050386e6e4933ec7e9ba37a9360b095beba..5a991ee5b86455c065912e8e1cea74bcb39b37e2 100644 --- a/developement.txt +++ b/developement.txt @@ -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 diff --git a/final_project/main.py b/final_project/main.py index 3002b94866e1e71f65e92d14e33d0a2f8ded6b79..9be031afa7a71fc4a96b084e886ac3d8e0f23cef 100644 --- a/final_project/main.py +++ b/final_project/main.py @@ -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) diff --git a/final_project/mouse_class.py b/final_project/mouse_class.py index 0af223bed3e107d8ccc3dfb2fef39bc96022b2a6..fdb9bbadbba3a85aef18221b79d2a45dea7cc377 100644 --- a/final_project/mouse_class.py +++ b/final_project/mouse_class.py @@ -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)