- Interactive mission selector with metadata-driven design - 5 educational missions (basics + advanced) - AI assistant roles (Deepbit, Bugsy, Schnippsi, Tobi) - SnakeCam gesture recognition system - Token tracking utilities - CLAUDE.md documentation - .gitignore for logs and secrets
36 lines
1.2 KiB
Plaintext
Executable File
36 lines
1.2 KiB
Plaintext
Executable File
import cv2
|
||
import numpy as np
|
||
|
||
# --- Handgestenerkennung: Einfacher Hautfarbfilter + Konturanalyse ---
|
||
def detect_hand_gesture(frame):
|
||
# Region of Interest (z. B. linke obere Ecke) definieren
|
||
roi = frame[20:120, 20:120]
|
||
|
||
# Konvertiere in HSV-Farbraum
|
||
hsv = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV)
|
||
|
||
# Hautfarb-Bereich (kann je nach Licht angepasst werden)
|
||
lower_skin = np.array([0, 30, 60], dtype=np.uint8)
|
||
upper_skin = np.array([20, 150, 255], dtype=np.uint8)
|
||
|
||
# Maske für Hautfarbe erzeugen
|
||
mask = cv2.inRange(hsv, lower_skin, upper_skin)
|
||
|
||
# Konturen finden
|
||
contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
||
|
||
gesture = "none"
|
||
|
||
# Wenn große Kontur gefunden → einfache „Winken“-Simulation
|
||
if contours:
|
||
largest_contour = max(contours, key=cv2.contourArea)
|
||
if cv2.contourArea(largest_contour) > 1000:
|
||
gesture = "wave"
|
||
|
||
# ROI im Hauptframe markieren
|
||
cv2.rectangle(frame, (20, 20), (120, 120), (0, 255, 0), 2)
|
||
cv2.putText(frame, f"Gesture: {gesture}", (20, 160),
|
||
cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2)
|
||
|
||
return gesture, frame
|