Files
crumbmissions/snake_camera_vision_v2/gestures/gestures.py.v1
Branko May Trinkwald 2915828adf Add complete Crumbforest mission system
- 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
2025-12-21 01:16:48 +01:00

36 lines
1.2 KiB
Plaintext
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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