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

Grab is moving

parent 2c16d4eb
Branches
No related tags found
No related merge requests found
......@@ -81,6 +81,9 @@ class Mouse:
# THIS FUNCTION NOT WORKS ON WINDOWS
elif prediction == "drag":
pyautogui.mouseDown()
hand_x = np.clip(int(self.hand_pos_x*WIDTH), 0, WIDTH-1)
hand_y = np.clip(int(self.hand_pos_y*HEIGHT), 0, HEIGHT-1)
pyautogui.moveTo(hand_x, hand_y)
elif prediction == "drop":
pyautogui.mouseUp()
elif prediction == "multiple item selection grab":
......@@ -191,9 +194,9 @@ def main():
cv2.putText(img = frameRGB, text = pred[0], org = (30,30),
fontFace = cv2.FONT_HERSHEY_DUPLEX, fontScale = 1, color = (255, 0, 0), thickness = 1)
mouse.add_prediction(mouse_command)
if mouse_command == "move cursor":
mouse.get_hand_pos(landmark_list[8])
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment