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

remove left hand actions when it is not detected

parent c15cf8e7
Branches main
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import numpy as np
from sklearn.ensemble import RandomForestClassifier
from tkinter import Tk, Label
from PIL import Image, ImageTk
import pyautogui
from mouse_class import Mouse
from keyboard_class import Keyboard
......@@ -96,7 +97,7 @@ def main():
command = pred[0]
mouse.add_prediction(command)
if command == "move cursor" or command == "grab":
if command == "move cursor" or command == "drag":
mouse.get_hand_size(right_landmark_list[12], right_landmark_list[0])
mouse.get_hand_pos(right_landmark_list[9])
elif command == "change the model":
......@@ -119,7 +120,7 @@ def main():
cv2.putText(
img=frameRGB,
text=f"{pred[0]} pos {right_landmark_list[8][0]:.2f}, {right_landmark_list[8][1]:.2f}, {MOUSE_ACTIVE}",
text=f"{pred[0]}, MOUSE: {MOUSE_ACTIVE}",
org=(30, 30), fontFace=cv2.FONT_HERSHEY_DUPLEX, fontScale=1, color=(255, 0, 0), thickness=1
)
......@@ -143,11 +144,15 @@ def main():
pred = model_specialkeys.predict(np.asarray(normalised_left_landmark_list).reshape(1, -1))
command = pred[0]
cv2.putText(
img=frameRGB, text=pred[0], org=(30, 30),
img=frameRGB, text=pred[0], org=(30, 60),
fontFace=cv2.FONT_HERSHEY_DUPLEX, fontScale=1, color=(0, 255, 0), thickness=1
)
specialkeys.add_prediction(command)
else:
pyautogui.keyUp('shift')
pyautogui.keyUp('ctrl')
pyautogui.keyUp('alt')
# Convert frame to Tkinter-compatible format and display
frameRGB_resized = cv2.resize(frameRGB, (root.winfo_width(), root.winfo_height()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment