import cv2 import numpy as np def detect_hand_gesture(frame): x, y, w, h = 100, 100, 200, 150 roi = frame[y:y+h, x:x+w] hsv = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) # Hautfarbe grob einschränken lower_skin = np.array([0, 30, 60], dtype=np.uint8) upper_skin = np.array([20, 150, 255], dtype=np.uint8) mask = cv2.inRange(hsv, lower_skin, upper_skin) mask = cv2.GaussianBlur(mask, (5, 5), 0) contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) gesture = "none" if contours: contour = max(contours, key=cv2.contourArea) area = cv2.contourArea(contour) if area > 3000: print(f"[debug] Fläche erkannt: {int(area)}") gesture = "hand" return gesture, (x, y, w, h)