I'm trying to make a mouse that recognizes gestures via mediapipe and interprets them as actions. In this case, I implemented the movement of the mouse and the click, but when implementing the drag (dragTo) the program generates problems for me.
I want to make the gesture of closing the hand interpret as a drag. For example to drag folders on the desktop (the same thing that happens when you press the left mouse button and leave it pressed).
def Arrastrar(hand_landmarks, height, widith):
bandera = False
#MARCADORES DE INTERES
x_0 = int(hand_landmarks.landmark[0].x*widith)
y_0 = int(hand_landmarks.landmark[0].y*height)
x_6 = int(hand_landmarks.landmark[6].x*widith)
y_6 = int(hand_landmarks.landmark[6].y*height)
x_8 = int(hand_landmarks.landmark[8].x*widith)
y_8 = int(hand_landmarks.landmark[8].y*height)
x_18 = int(hand_landmarks.landmark[18].x*widith)
y_18 = int(hand_landmarks.landmark[18].y*height)
x_20 = int(hand_landmarks.landmark[20].x*widith)
y_20 = int(hand_landmarks.landmark[20].y*height)
#CALCULO PUNTOS
p_0 = Calculo_Punto(x_0, y_0)
p_5 = Calculo_Punto(x_6, y_6)
p_8 = Calculo_Punto(x_8, y_8)
p_17 = Calculo_Punto(x_18, y_18)
p_20 = Calculo_Punto(x_20, y_20)
dist_p0_p_6 = math.sqrt((x_6 - x_0)**2 + (y_6 - y_0)**2)
dist_p0_p_8 = math.sqrt((x_8 - x_0)**2 + (y_8 - y_0)**2)
dist_p0_p_18 = math.sqrt((x_18 - x_0)**2 + (y_18 - y_0)**2)
dist_p0_p_20 = math.sqrt((x_20 - x_0)**2 + (y_20 - y_0)**2)
elif bandera_arrastre == True and bandera_mov == False and bandera_click == False:
xm_a = np.interp(x_a, (X_Y_INI, X_Y_INI + area_width), (X_INI, X_FIN))
ym_a = np.interp(y_a, (X_Y_INI, X_Y_INI + area_height), (Y_INI, Y_FIN))
pyautogui.dragTo((xm_a), (ym_a), 0.2, button = 'left')
x_last_drag = int(xm_a)
y_last_drag = int(ym_a)
pos_arr = f"xm_a = {int(xm_a)} ; ym_a = {int(ym_a)}"
mensaje = str('Arrastrando')