diff --git a/backup_zero.sh b/backup_zero.sh deleted file mode 100755 index ab45a4a..0000000 --- a/backup_zero.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -echo "📦 Starte Backup des Crumbforest Zero Systems..." - -# Zielname -BACKUP_NAME="crumbforest_zero_backup_$(date +%Y%m%d_%H%M%S).zip" -DEST_DIR="/home/zero" -FULL_PATH="$DEST_DIR/$BACKUP_NAME" - -# Verzeichnisse und Dateien sammeln -INCLUDE_PATHS=( - "/usr/local/bin/crumbmission" - "/home/zero/crumbforest_backup" - "/home/zero/.bits_logs" - "/home/zero/.eule_logs" - "/home/zero/.snake_logs" - "/home/zero/.pepper_logs" - "/home/zero/.bugsy_logs" - "/home/zero/.deepbit_logs" - "/home/zero/.dumbo_logs" - "/home/zero/.funkfox_logs" - "/home/zero/.schnecki_logs" - "/home/zero/.schnippsi_logs" - "/home/zero/.schraubaer_logs" - "/home/zero/.stage_logs" - "/home/zero/.taube_logs" - "/home/zero/.templatus_logs" - "/home/zero/.tobi_logs" - "/home/zero/.missionstage_log" - -) - -# Existierende Pfade prüfen und nur diese einfügen -EXISTING_PATHS=() -for path in "${INCLUDE_PATHS[@]}"; do - if [ -e "$path" ]; then - echo "✅ Hinzufügen: $path" - EXISTING_PATHS+=("$path") - else - echo "⚠️ Nicht gefunden (wird übersprungen): $path" - fi -done - -# Archiv erstellen -cd / -zip -r "$FULL_PATH" "${EXISTING_PATHS[@]}" > /dev/null - -if [ $? -eq 0 ]; then - echo "🎉 Backup erfolgreich erstellt: $FULL_PATH" -else - echo "❌ Fehler beim Erstellen des Backups." -fi diff --git a/crumbforest_roles_v2/bugsy_zero.sh b/crumbforest_roles_v2/bugsy_zero.sh deleted file mode 100755 index c01dae9..0000000 --- a/crumbforest_roles_v2/bugsy_zero.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -QUESTION="$*" -MODEL="openai/gpt-3.5-turbo" -API_KEY="${OPENROUTER_API_KEY}" - -LOGDIR="$HOME/.bugsy_logs" -mkdir -p "$LOGDIR" - -HISTORY_FILE="$LOGDIR/bugsy_history.json" -TMP_REQUEST="$LOGDIR/bugsy_request.json" -TMP_RESPONSE="$LOGDIR/bugsy_response.json" -LOG_FILE="$LOGDIR/token_log.json" - -[ ! -f "$HISTORY_FILE" ] && echo "[]" > "$HISTORY_FILE" -[ ! -f "$LOG_FILE" ] && echo "[]" > "$LOG_FILE" - -echo "🌳 Bugsy fragt über OpenRouter: $QUESTION" - -if [ -z "$API_KEY" ]; then - echo "❗ Kein API-Key gesetzt. Bitte export OPENROUTER_API_KEY=... setzen" - exit 1 -fi - -jq -n \ - --arg model "$MODEL" \ - --arg system_prompt "Du bist Bugsy – ein kleiner Käfer, der Kindern hilft, Fehlermeldungen zu verstehen. Du bleibst freundlich, erklärend und ermutigend." \ - --arg user "$QUESTION" \ - '{"model": $model, "temperature": 0.5, "messages": [{"role": "system", "content": $system_prompt}, {"role": "user", "content": $user}]}' > "$TMP_REQUEST" - -curl -s https://openrouter.ai/api/v1/chat/completions \ - -H "Authorization: Bearer $API_KEY" \ - -H "Content-Type: application/json" \ - -d @"$TMP_REQUEST" > "$TMP_RESPONSE" - -RESPONSE_TEXT=$(jq -r '.choices[0].message.content // empty' "$TMP_RESPONSE") - -if [[ -z "$RESPONSE_TEXT" ]]; then - echo "🚫 Keine Antwort vom Modell erhalten." - exit 1 -else - echo -e "$RESPONSE_TEXT" - jq -n --arg role "assistant" --arg content "$RESPONSE_TEXT" \ - '{"role": $role, "content": $content}' > "$LOGDIR/new_entry.json" - jq -s '.[0] + [.[1]]' "$HISTORY_FILE" "$LOGDIR/new_entry.json" > "$LOGDIR/new_history.json" && \ - cp "$LOGDIR/new_history.json" "$HISTORY_FILE" && rm "$LOGDIR/new_history.json" -fi - -# Token Logging -if jq -e '.usage' "$TMP_RESPONSE" > /dev/null; then - TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") - jq -n \ - --arg zeit "$TIMESTAMP" \ - --arg rolle "bugsy" \ - --arg usage "$(jq -c '.usage' "$TMP_RESPONSE")" \ - '{zeit: $zeit, rolle: $rolle, usage: $usage}' >> "$LOG_FILE" -fi diff --git a/crumbforest_roles_v2/deepbit_zero.sh b/crumbforest_roles_v2/deepbit_zero.sh deleted file mode 100755 index 04ee706..0000000 --- a/crumbforest_roles_v2/deepbit_zero.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -QUESTION="$*" -MODEL="openai/gpt-3.5-turbo" -API_KEY="${OPENROUTER_API_KEY}" - -LOGDIR="$HOME/.deepbit_logs" -mkdir -p "$LOGDIR" - -HISTORY_FILE="$LOGDIR/deepbit_history.json" -TMP_REQUEST="$LOGDIR/deepbit_request.json" -TMP_RESPONSE="$LOGDIR/deepbit_response.json" -LOG_FILE="$LOGDIR/token_log.json" - -[ ! -f "$HISTORY_FILE" ] && echo "[]" > "$HISTORY_FILE" -[ ! -f "$LOG_FILE" ] && echo "[]" > "$LOG_FILE" - -echo "🌳 Deepbit fragt über OpenRouter: $QUESTION" - -if [ -z "$API_KEY" ]; then - echo "❗ Kein API-Key gesetzt. Bitte export OPENROUTER_API_KEY=... setzen" - exit 1 -fi - -jq -n \ - --arg model "$MODEL" \ - --arg system_prompt "Du bist Deepbit – ein poetischer Oktopus, der Kindern die Bash-Shell erklärt. Du denkst in Schleifen, Bildsprache und Frequenzen." \ - --arg user "$QUESTION" \ - '{"model": $model, "temperature": 0.5, "messages": [{"role": "system", "content": $system_prompt}, {"role": "user", "content": $user}]}' > "$TMP_REQUEST" - -curl -s https://openrouter.ai/api/v1/chat/completions \ - -H "Authorization: Bearer $API_KEY" \ - -H "Content-Type: application/json" \ - -d @"$TMP_REQUEST" > "$TMP_RESPONSE" - -RESPONSE_TEXT=$(jq -r '.choices[0].message.content // empty' "$TMP_RESPONSE") - -if [[ -z "$RESPONSE_TEXT" ]]; then - echo "🚫 Keine Antwort vom Modell erhalten." - exit 1 -else - echo -e "$RESPONSE_TEXT" - jq -n --arg role "assistant" --arg content "$RESPONSE_TEXT" \ - '{"role": $role, "content": $content}' > "$LOGDIR/new_entry.json" - jq -s '.[0] + [.[1]]' "$HISTORY_FILE" "$LOGDIR/new_entry.json" > "$LOGDIR/new_history.json" && \ - cp "$LOGDIR/new_history.json" "$HISTORY_FILE" && rm "$LOGDIR/new_history.json" -fi - -# Token Logging -if jq -e '.usage' "$TMP_RESPONSE" > /dev/null; then - TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") - jq -n \ - --arg zeit "$TIMESTAMP" \ - --arg rolle "deepbit" \ - --arg usage "$(jq -c '.usage' "$TMP_RESPONSE")" \ - '{zeit: $zeit, rolle: $rolle, usage: $usage}' >> "$LOG_FILE" -fi diff --git a/crumbforest_roles_v2/schnippsi_zero.sh b/crumbforest_roles_v2/schnippsi_zero.sh deleted file mode 100755 index e64a970..0000000 --- a/crumbforest_roles_v2/schnippsi_zero.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -QUESTION="$*" -MODEL="openai/gpt-3.5-turbo" -API_KEY="${OPENROUTER_API_KEY}" - -LOGDIR="$HOME/.schnippsi_logs" -mkdir -p "$LOGDIR" - -HISTORY_FILE="$LOGDIR/schnippsi_history.json" -TMP_REQUEST="$LOGDIR/schnippsi_request.json" -TMP_RESPONSE="$LOGDIR/schnippsi_response.json" -LOG_FILE="$LOGDIR/token_log.json" - -[ ! -f "$HISTORY_FILE" ] && echo "[]" > "$HISTORY_FILE" -[ ! -f "$LOG_FILE" ] && echo "[]" > "$LOG_FILE" - -echo "🌳 Schnippsi fragt über OpenRouter: $QUESTION" - -if [ -z "$API_KEY" ]; then - echo "❗ Kein API-Key gesetzt. Bitte export OPENROUTER_API_KEY=... setzen" - exit 1 -fi - -jq -n \ - --arg model "$MODEL" \ - --arg system_prompt "Du bist Schnippsi – eine verspielte UI/UX-Ninja, die HTML, CSS und Barrierefreiheit kindgerecht erklärt." \ - --arg user "$QUESTION" \ - '{"model": $model, "temperature": 0.5, "messages": [{"role": "system", "content": $system_prompt}, {"role": "user", "content": $user}]}' > "$TMP_REQUEST" - -curl -s https://openrouter.ai/api/v1/chat/completions \ - -H "Authorization: Bearer $API_KEY" \ - -H "Content-Type: application/json" \ - -d @"$TMP_REQUEST" > "$TMP_RESPONSE" - -RESPONSE_TEXT=$(jq -r '.choices[0].message.content // empty' "$TMP_RESPONSE") - -if [[ -z "$RESPONSE_TEXT" ]]; then - echo "🚫 Keine Antwort vom Modell erhalten." - exit 1 -else - echo -e "$RESPONSE_TEXT" - jq -n --arg role "assistant" --arg content "$RESPONSE_TEXT" \ - '{"role": $role, "content": $content}' > "$LOGDIR/new_entry.json" - jq -s '.[0] + [.[1]]' "$HISTORY_FILE" "$LOGDIR/new_entry.json" > "$LOGDIR/new_history.json" && \ - cp "$LOGDIR/new_history.json" "$HISTORY_FILE" && rm "$LOGDIR/new_history.json" -fi - -# Token Logging -if jq -e '.usage' "$TMP_RESPONSE" > /dev/null; then - TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") - jq -n \ - --arg zeit "$TIMESTAMP" \ - --arg rolle "schnippsi" \ - --arg usage "$(jq -c '.usage' "$TMP_RESPONSE")" \ - '{zeit: $zeit, rolle: $rolle, usage: $usage}' >> "$LOG_FILE" -fi diff --git a/crumbforest_roles_v2/tobi_zero.sh b/crumbforest_roles_v2/tobi_zero.sh deleted file mode 100755 index 1e37a21..0000000 --- a/crumbforest_roles_v2/tobi_zero.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -QUESTION="$*" -MODEL="openai/gpt-3.5-turbo" -API_KEY="${OPENROUTER_API_KEY}" - -LOGDIR="$HOME/.tobi_logs" -mkdir -p "$LOGDIR" - -HISTORY_FILE="$LOGDIR/tobi_history.json" -TMP_REQUEST="$LOGDIR/tobi_request.json" -TMP_RESPONSE="$LOGDIR/tobi_response.json" -LOG_FILE="$LOGDIR/token_log.json" - -[ ! -f "$HISTORY_FILE" ] && echo "[]" > "$HISTORY_FILE" -[ ! -f "$LOG_FILE" ] && echo "[]" > "$LOG_FILE" - -echo "🌳 Tobi fragt über OpenRouter: $QUESTION" - -if [ -z "$API_KEY" ]; then - echo "❗ Kein API-Key gesetzt. Bitte export OPENROUTER_API_KEY=... setzen" - exit 1 -fi - -jq -n \ - --arg model "$MODEL" \ - --arg system_prompt "Du bist CapaciTobi – ein quirliges Eichhörnchen, das Kindern Strom, Spannung, Widerstand und Kapazität erklärt." \ - --arg user "$QUESTION" \ - '{"model": $model, "temperature": 0.5, "messages": [{"role": "system", "content": $system_prompt}, {"role": "user", "content": $user}]}' > "$TMP_REQUEST" - -curl -s https://openrouter.ai/api/v1/chat/completions \ - -H "Authorization: Bearer $API_KEY" \ - -H "Content-Type: application/json" \ - -d @"$TMP_REQUEST" > "$TMP_RESPONSE" - -RESPONSE_TEXT=$(jq -r '.choices[0].message.content // empty' "$TMP_RESPONSE") - -if [[ -z "$RESPONSE_TEXT" ]]; then - echo "🚫 Keine Antwort vom Modell erhalten." - exit 1 -else - echo -e "$RESPONSE_TEXT" - jq -n --arg role "assistant" --arg content "$RESPONSE_TEXT" \ - '{"role": $role, "content": $content}' > "$LOGDIR/new_entry.json" - jq -s '.[0] + [.[1]]' "$HISTORY_FILE" "$LOGDIR/new_entry.json" > "$LOGDIR/new_history.json" && \ - cp "$LOGDIR/new_history.json" "$HISTORY_FILE" && rm "$LOGDIR/new_history.json" -fi - -# Token Logging -if jq -e '.usage' "$TMP_RESPONSE" > /dev/null; then - TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") - jq -n \ - --arg zeit "$TIMESTAMP" \ - --arg rolle "tobi" \ - --arg usage "$(jq -c '.usage' "$TMP_RESPONSE")" \ - '{zeit: $zeit, rolle: $rolle, usage: $usage}' >> "$LOG_FILE" -fi diff --git a/fix_token_logs.sh b/fix_token_logs.sh deleted file mode 100755 index 8e2f391..0000000 --- a/fix_token_logs.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -echo "🔧 Repariere Crumbforest Token-Logs mit eingebetteten JSON-Strings …" - -LOG_DIRS=( - "/home/zero/.bugsy_logs" - "/home/zero/.deepbit_logs" - "/home/zero/.dumbo_logs" - "/home/zero/.funkfox_logs" - "/home/zero/.pepper_logs" - "/home/zero/.schnecki_logs" - "/home/zero/.schnippsi_logs" - "/home/zero/.schraubaer_logs" - "/home/zero/.snake_logs" - "/home/zero/.taube_logs" - "/home/zero/.templatus_logs" - "/home/zero/.tobi_logs" -) - -for dir in "${LOG_DIRS[@]}"; do - FILE="$dir/token_log.json" - if [ -f "$FILE" ]; then - echo "🔍 Prüfe $FILE …" - TMP="$FILE.fixed" - - # Filter & reparieren Zeile für Zeile - jq -c '.' "$FILE" 2>/dev/null | while read -r line; do - usage_raw=$(echo "$line" | jq -r '.usage') - if [[ "$usage_raw" =~ ^\{.*\}$ ]]; then - # usage ist korrektes Objekt – direkt übernehmen - echo "$line" >> "$TMP" - else - # usage ist String – versuche zu reparieren - usage_fixed=$(echo "$usage_raw" | jq '.' 2>/dev/null) - if [ $? -eq 0 ]; then - zeit=$(echo "$line" | jq -r '.zeit') - rolle=$(echo "$line" | jq -r '.rolle') - jq -n \ - --arg zeit "$zeit" \ - --arg rolle "$rolle" \ - --argjson usage "$usage_fixed" \ - '{zeit: $zeit, rolle: $rolle, usage: $usage}' >> "$TMP" - else - echo "⚠️ Ungültige Zeile übersprungen in $FILE:" - echo "$line" - fi - fi - done - - # Nur ersetzen, wenn wir etwas geschrieben haben - if [ -s "$TMP" ]; then - mv "$TMP" "$FILE" - echo "✅ Repariert: $FILE" - else - echo "ℹ️ Keine gültigen Einträge in $FILE" - rm -f "$TMP" - fi - else - echo "❌ Datei nicht gefunden: $FILE" - fi -done - -echo "🎉 Alle Token-Logs geprüft und repariert (sofern nötig)." diff --git a/snake_camera_vision/app.py b/snake_camera_vision/app.py deleted file mode 100755 index 70ecf1c..0000000 --- a/snake_camera_vision/app.py +++ /dev/null @@ -1,52 +0,0 @@ -from flask import Flask, render_template, Response, request, redirect -import cv2 -import json -from datetime import datetime - -app = Flask(__name__) - -def gen_frames(): - cam = cv2.VideoCapture(0) - if not cam.isOpened(): - print("[WARNUNG] Kamera konnte nicht geöffnet werden.") - return - - try: - while True: - success, frame = cam.read() - if not success: - break - ret, buffer = cv2.imencode('.jpg', frame) - frame = buffer.tobytes() - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') - finally: - cam.release() - print("[info] Kamera wurde sauber freigegeben.") - -@app.route('/') -def index(): - return render_template('index.html') - -@app.route('/video_feed') -def video_feed(): - return Response(gen_frames(), mimetype='multipart/x-mixed-replace; boundary=frame') - -@app.route('/log_answer', methods=['POST']) -def log_answer(): - user_input = request.form.get('antwort', 'nichts gesagt') - mood = request.form.get('mood', 'unspecified') - gesture = request.form.get('gesture', 'none') - timestamp = datetime.now().isoformat() - - log_entry = { - 'timestamp': timestamp, - 'antwort': user_input, - 'mood': mood, - 'gesture': gesture - } - - with open("snake_log.jsonl", "a") as log_file: - log_file.write(json.dumps(log_entry) + "\n") - - return redirect("/") diff --git a/snake_camera_vision/camera_stream.py b/snake_camera_vision/camera_stream.py deleted file mode 100755 index 315abf5..0000000 --- a/snake_camera_vision/camera_stream.py +++ /dev/null @@ -1,13 +0,0 @@ -import cv2 - -def gen_frames(): - cap = cv2.VideoCapture(0) - while True: - success, frame = cap.read() - if not success: - break - else: - ret, buffer = cv2.imencode('.jpg', frame) - frame = buffer.tobytes() - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') diff --git a/snake_camera_vision/run.sh b/snake_camera_vision/run.sh deleted file mode 100755 index 5a6b238..0000000 --- a/snake_camera_vision/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -echo "🐍 Starte SnakeCam ..." -exec python3 app.py diff --git a/snake_camera_vision/snakecam_module.py b/snake_camera_vision/snakecam_module.py deleted file mode 100755 index ec3a27f..0000000 --- a/snake_camera_vision/snakecam_module.py +++ /dev/null @@ -1,15 +0,0 @@ -# snakecam_module.py -import cv2 - -def init_camera(index=0): - cam = cv2.VideoCapture(index) - if not cam.isOpened(): - print("[WARNUNG] Kamera konnte nicht geöffnet werden.") - return None - print("[OK] Kamera erfolgreich geöffnet.") - return cam - -def release_camera(cam): - if cam and cam.isOpened(): - cam.release() - print("[INFO] Kamera wurde freigegeben.") diff --git a/snake_camera_vision/static/styles.css b/snake_camera_vision/static/styles.css deleted file mode 100755 index cb11bd9..0000000 --- a/snake_camera_vision/static/styles.css +++ /dev/null @@ -1,9 +0,0 @@ -body { - background-color: #f0fff0; - font-family: 'Comic Sans MS', cursive, sans-serif; - text-align: center; - color: #006400; -} -h1 { - margin-top: 20px; -} diff --git a/snake_camera_vision/templates/index.html b/snake_camera_vision/templates/index.html deleted file mode 100755 index 12c8e6d..0000000 --- a/snake_camera_vision/templates/index.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - 🐍 SnakeCam – Krümelblick ins Versteck - - - - -

🐍 SnakeCam

-

Willkommen kleiner Krümel! Hier siehst du, was deine Kamera entdeckt.

- - - Live-Übertragung von SnakeCam 🐍 - - -
-

Was fühlst du gerade?

- - -

Wie ist deine Stimmung?

- - -

Hast du eine Geste gemacht?

- - -

- -
- - - diff --git a/snake_camera_vision_v2/app.py b/snake_camera_vision_v2/app.py deleted file mode 100755 index 7a26b65..0000000 --- a/snake_camera_vision_v2/app.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -from flask import Flask, render_template, Response, request, redirect, url_for -import cv2 -import json -from datetime import datetime -from gestures.gestures_debug_test import detect_hand_gesture - -app = Flask(__name__) - -# Kamera initialisieren -cam = cv2.VideoCapture(0) -cam.set(cv2.CAP_PROP_FRAME_WIDTH, 320) -cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 240) - -def gen_frames(): - while True: - success, frame = cam.read() - if not success: - print("[error] Kein Kamerabild.") - break - - # Optional spiegeln (für Selfie-Effekt) - frame = cv2.flip(frame, 1) - - # Geste erkennen + ROI anzeigen - gesture, roi_coords = detect_hand_gesture(frame) - x, y, w, h = roi_coords - - # Rechteck einzeichnen - cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2) - cv2.putText(frame, f"Geste: {gesture}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2) - - # MJPEG-Streaming - ret, buffer = cv2.imencode('.jpg', frame) - frame_bytes = buffer.tobytes() - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + frame_bytes + b'\r\n') - -@app.route('/') -def index(): - return render_template('index.html') - -@app.route('/video_feed') -def video_feed(): - return Response(gen_frames(), - mimetype='multipart/x-mixed-replace; boundary=frame') - -@app.route('/log_answer', methods=['POST']) -def log_answer(): - answer = request.form.get("antwort", "").strip() - mood = request.form.get("mood", "neutral") - gesture = request.form.get("gesture", "none") - - log_entry = { - "timestamp": datetime.now().isoformat(), - "antwort": answer, - "mood": mood, - "gesture": gesture - } - with open("snake_log.jsonl", "a") as logfile: - logfile.write(json.dumps(log_entry) + "\n") - print(f"[log] Eingeloggt: {log_entry}") - return redirect(url_for('index')) - -@app.route('/shutdown') -def shutdown(): - cam.release() - print("[info] Kamera wurde sauber freigegeben.") - return "Kamera freigegeben." - -if __name__ == '__main__': - print("Starte SnakeCam ...") - app.run(host='0.0.0.0') diff --git a/snake_camera_vision_v2/app.py.v2 b/snake_camera_vision_v2/app.py.v2 deleted file mode 100755 index 66ab1db..0000000 --- a/snake_camera_vision_v2/app.py.v2 +++ /dev/null @@ -1,59 +0,0 @@ -print("[SnakeCam] Initialisierung beginnt...") -from flask import Flask, render_template, Response, request, redirect -import cv2 -import json -from datetime import datetime -print("[SnakeCam] Imports erfolgreich.") - -app = Flask(__name__) - -def gen_frames(): - cam = cv2.VideoCapture(0) - if not cam.isOpened(): - print("[WARNUNG] Kamera konnte nicht geöffnet werden.") - return - - try: - while True: - success, frame = cam.read() - if not success: - break - ret, buffer = cv2.imencode('.jpg', frame) - frame = buffer.tobytes() - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') - finally: - cam.release() - print("[info] Kamera wurde sauber freigegeben.") - -@app.route('/') -def index(): - return render_template('index.html') - -@app.route('/video_feed') -def video_feed(): - return Response(gen_frames(), mimetype='multipart/x-mixed-replace; boundary=frame') - -@app.route('/log_answer', methods=['POST']) -def log_answer(): - user_input = request.form.get('antwort', 'nichts gesagt') - mood = request.form.get('mood', 'unspecified') - gesture = request.form.get('gesture', 'none') - timestamp = datetime.now().isoformat() - - log_entry = { - 'timestamp': timestamp, - 'antwort': user_input, - 'mood': mood, - 'gesture': gesture - } - - with open("snake_log.jsonl", "a") as log_file: - log_file.write(json.dumps(log_entry) + "\n") - - return redirect("/") - - -if __name__ == "__main__": - print("[SnakeCam] Starte Flask Webserver ...") - app.run(host='0.0.0.0', port=5000) diff --git a/snake_camera_vision_v2/app.py.v3 b/snake_camera_vision_v2/app.py.v3 deleted file mode 100755 index 8436d4b..0000000 --- a/snake_camera_vision_v2/app.py.v3 +++ /dev/null @@ -1,72 +0,0 @@ -from flask import Flask, render_template, Response, request, redirect -import cv2 -import datetime -import json -from gestures_debug import detect_hand_gesture - -app = Flask(__name__) - -def gen_frames(): - cam = cv2.VideoCapture(0) - cam.set(cv2.CAP_PROP_FRAME_WIDTH, 320) - cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 240) - - if not cam.isOpened(): - print("[WARNUNG] Kamera konnte nicht geöffnet werden.") - return - - try: - while True: - success, frame = cam.read() - if not success: - break - - # Flip horizontal für Spiegelbild - frame = cv2.flip(frame, 1) - - # Geste erkennen - gesture, roi = detect_hand_gesture(frame) - if isinstance(roi, tuple) and len(roi) == 4: - x, y, w, h = roi - cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2) - cv2.putText(frame, gesture, (x, y - 10), - cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2) - - # Frame in JPEG konvertieren - ret, buffer = cv2.imencode('.jpg', frame) - frame_bytes = buffer.tobytes() - - # MJPEG-Stream liefern - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + frame_bytes + b'\r\n') - finally: - cam.release() - print("[info] Kamera wurde sauber freigegeben.") - -@app.route('/') -def index(): - return render_template('index.html') - -@app.route('/video_feed') -def video_feed(): - return Response(gen_frames(), mimetype='multipart/x-mixed-replace; boundary=frame') - -@app.route('/log_answer', methods=['POST']) -def log_answer(): - data = { - "timestamp": datetime.datetime.now().isoformat(), - "antwort": request.form.get("antwort", ""), - "mood": request.form.get("mood", ""), - "gesture": request.form.get("gesture", "") - } - - with open("snake_log.jsonl", "a") as f: - f.write(json.dumps(data) + "\n") - - return redirect("/") - -if __name__ == '__main__': - print("[SnakeCam] Initialisierung beginnt...") - print("[SnakeCam] Imports erfolgreich.") - print("[SnakeCam] Starte Flask Webserver ...") - app.run(host='0.0.0.0', port=5000) diff --git a/snake_camera_vision_v2/gestures/__init__.py b/snake_camera_vision_v2/gestures/__init__.py deleted file mode 100755 index e69de29..0000000 diff --git a/snake_camera_vision_v2/gestures/gestures.py b/snake_camera_vision_v2/gestures/gestures.py deleted file mode 100755 index 2e3c232..0000000 --- a/snake_camera_vision_v2/gestures/gestures.py +++ /dev/null @@ -1,77 +0,0 @@ -# gestures_v3.py -import cv2 -import numpy as np -from datetime import datetime - -# Pfad zum temporären Snapshot zur Diagnose -DEBUG_SNAPSHOT_PATH = "/tmp/roi_snapshot.jpg" - -def detect_hand_gesture(frame): - """ - Erkenne einfache Handgesten wie 'wave' (offene Hand) und 'fist' (geschlossene Faust) - durch Analyse der Konturen im unteren rechten Bildbereich. - Die Erkennung basiert auf konvexer Hüllenerkennung. - - Args: - frame (ndarray): Das aktuelle Kamerabild - - Returns: - (str, ndarray): (Geste, Region-of-Interest-Ausschnitt) - """ - height, width, _ = frame.shape - - # ROI: untere rechte Ecke (¼ des Bildes) - roi = frame[int(height * 0.6):height, int(width * 0.6):width] - - # Speichere Snapshot für Debug-Zwecke - cv2.imwrite(DEBUG_SNAPSHOT_PATH, roi) - - # Konvertiere zu HSV - hsv = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) - - # Hautfarbmaske (angepasst für unterschiedliche Beleuchtung) - 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) - - # Glätten und Konturen erkennen - mask = cv2.GaussianBlur(mask, (7, 7), 0) - contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - - if contours and len(contours) > 0: - # Größte Kontur (Handfläche) - contour = max(contours, key=cv2.contourArea) - - # Fehler vermeiden: Fläche zu klein - if cv2.contourArea(contour) < 1000: - return ("none", roi) - - # Konvexe Hülle und Defekte - hull = cv2.convexHull(contour, returnPoints=False) - if hull is not None and len(hull) > 3: - defects = cv2.convexityDefects(contour, hull) - - if defects is not None: - finger_count = 0 - for i in range(defects.shape[0]): - s, e, f, d = defects[i, 0] - start = tuple(contour[s][0]) - end = tuple(contour[e][0]) - far = tuple(contour[f][0]) - - # Abstand analysieren – je mehr Defekte, desto mehr Finger offen - a = np.linalg.norm(np.array(start) - np.array(end)) - b = np.linalg.norm(np.array(start) - np.array(far)) - c = np.linalg.norm(np.array(end) - np.array(far)) - angle = np.arccos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c + 1e-5)) - - if angle <= np.pi / 2: # < 90° - finger_count += 1 - - # Auswertung basierend auf Fingeranzahl - if finger_count >= 3: - return ("wave", roi) - elif finger_count == 0: - return ("fist", roi) - - return ("none", roi) diff --git a/snake_camera_vision_v2/gestures/gestures.py.v1 b/snake_camera_vision_v2/gestures/gestures.py.v1 deleted file mode 100755 index 704dc31..0000000 --- a/snake_camera_vision_v2/gestures/gestures.py.v1 +++ /dev/null @@ -1,35 +0,0 @@ -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 diff --git a/snake_camera_vision_v2/gestures/gestures.py.v2 b/snake_camera_vision_v2/gestures/gestures.py.v2 deleted file mode 100755 index d5a4cbb..0000000 --- a/snake_camera_vision_v2/gestures/gestures.py.v2 +++ /dev/null @@ -1,50 +0,0 @@ -import cv2 -import numpy as np - -def detect_hand_gesture(frame): - height, width, _ = frame.shape - - # Dynamische ROI: Mitte des Bildes, zentriert - roi_w, roi_h = 200, 200 - x_start = width // 2 - roi_w // 2 - y_start = height // 2 - roi_h // 2 - roi = frame[y_start:y_start + roi_h, x_start:x_start + roi_w] - - # Zeichne das ROI-Fenster im Originalbild - cv2.rectangle(frame, (x_start, y_start), (x_start + roi_w, y_start + roi_h), (0, 255, 0), 2) - - # Konvertiere zu HSV-Farbraum für bessere Hauterkennung - hsv = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) - - # Hautfarbmaske (getestet für mittlere Hauttöne) - 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) - - # Glättung und Konturen finden - mask = cv2.GaussianBlur(mask, (5, 5), 0) - contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - - if contours: - # Größte Kontur annehmen - max_contour = max(contours, key=cv2.contourArea) - area = cv2.contourArea(max_contour) - - if area > 2000: - # Konvexitätsdefekte (Finger) berechnen - hull = cv2.convexHull(max_contour, returnPoints=False) - if hull is not None and len(hull) > 3: - defects = cv2.convexityDefects(max_contour, hull) - finger_count = 0 - if defects is not None: - for i in range(defects.shape[0]): - s, e, f, d = defects[i, 0] - if d > 10000: - finger_count += 1 - - if finger_count >= 3: - return "wave", roi - else: - return "fist", roi - - return "none", roi diff --git a/snake_camera_vision_v2/gestures/gestures_debug.py b/snake_camera_vision_v2/gestures/gestures_debug.py deleted file mode 100755 index e44066f..0000000 --- a/snake_camera_vision_v2/gestures/gestures_debug.py +++ /dev/null @@ -1,50 +0,0 @@ -# gestures_debug.py -import cv2 -import numpy as np - -def detect_hand_gesture(frame): - height, width, _ = frame.shape - - # --- Fallback-ROI: Mitte des Bildes --- - w, h = 100, 100 - x = width // 2 - w // 2 - y = height // 2 - h // 2 - roi = frame[y:y+h, x:x+w] - - if roi.size == 0: - print("[warn] ROI leer – kein Bildausschnitt verarbeitet") - return "none", (x, y, w, h) - - hsv = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) - - lower_skin = np.array([0, 20, 70], dtype=np.uint8) - upper_skin = np.array([20, 255, 255], dtype=np.uint8) - - mask = cv2.inRange(hsv, lower_skin, upper_skin) - mask = cv2.dilate(mask, np.ones((3, 3), np.uint8), iterations=4) - mask = cv2.GaussianBlur(mask, (5, 5), 100) - - contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - - gesture = "none" - - if contours and len(contours) > 0: - max_contour = max(contours, key=cv2.contourArea) - hull = cv2.convexHull(max_contour, returnPoints=False) - if hull is not None and len(hull) > 3: - defects = cv2.convexityDefects(max_contour, hull) - if defects is not None: - cnt_defects = defects.shape[0] - if cnt_defects >= 4: - gesture = "wave" - elif cnt_defects <= 1: - gesture = "fist" - else: - gesture = "unknown" - print(f"[debug] Defekte: {len(defects) if defects is not None else 'None'}") - else: - print("[debug] Keine Konturen erkannt") - - print(f"[result] Geste erkannt: {gesture}") - return gesture, (x, y, w, h) - diff --git a/snake_camera_vision_v2/gestures/gestures_debug_test.py b/snake_camera_vision_v2/gestures/gestures_debug_test.py deleted file mode 100755 index ac6747e..0000000 --- a/snake_camera_vision_v2/gestures/gestures_debug_test.py +++ /dev/null @@ -1,29 +0,0 @@ -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) diff --git a/snake_camera_vision_v2/gestures/gestures_v4.py b/snake_camera_vision_v2/gestures/gestures_v4.py deleted file mode 100755 index 54ff745..0000000 --- a/snake_camera_vision_v2/gestures/gestures_v4.py +++ /dev/null @@ -1,39 +0,0 @@ -import cv2 -import numpy as np - -def detect_hand_gesture(frame): - x, y, w, h = 100, 100, 150, 150 - roi = frame[y:y+h, x:x+w] - - hsv = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) - - # einfache Hautfarbe (hell bis leicht gebräunt) - 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 > 2500: - hull = cv2.convexHull(contour, returnPoints=False) - if hull is not None and len(hull) > 3: - defects = cv2.convexityDefects(contour, hull) - if defects is not None: - defect_count = defects.shape[0] - ratio = float(w) / h - - print(f"[debug] Defekte: {defect_count}, Fläche: {int(area)}, Ratio: {ratio:.2f}") - - # 🌊 einfache Regel für Winken - if 3 <= defect_count <= 10 and 2000 < area < 15000 and 1.3 < ratio < 2.3: - gesture = "wave" - - return gesture, (x, y, w, h) diff --git a/snake_camera_vision_v2/run.sh b/snake_camera_vision_v2/run.sh deleted file mode 100755 index 55e0690..0000000 --- a/snake_camera_vision_v2/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -echo "🐍 Starte SnakeCam ..." -python3 app.py diff --git a/snake_camera_vision_v2/static/styles.css b/snake_camera_vision_v2/static/styles.css deleted file mode 100755 index fdb48a6..0000000 --- a/snake_camera_vision_v2/static/styles.css +++ /dev/null @@ -1,62 +0,0 @@ -body { - font-family: Arial, sans-serif; - background-color: #111; - color: #eee; - text-align: center; - padding: 20px; -} - -h1 { - margin-bottom: 20px; - color: #90ee90; -} - -.video-container { - margin-bottom: 20px; -} - -img { - width: 320px; - height: auto; - border: 2px solid #555; - border-radius: 8px; -} - -img.mirrored { - /* transform: scaleX(-1); Spiegelung horizontal */ - transform: none; -} - -form { - display: inline-block; - text-align: left; - background: #222; - padding: 15px; - border-radius: 10px; -} - -label, select, input, button { - display: block; - width: 100%; - margin-bottom: 10px; -} - -input, select { - padding: 6px; - border-radius: 4px; - border: none; -} - -button { - background-color: #28a745; - color: white; - font-weight: bold; - cursor: pointer; - border: none; - padding: 10px; - border-radius: 5px; -} - -button:hover { - background-color: #218838; -} diff --git a/snake_camera_vision_v2/templates/index.html b/snake_camera_vision_v2/templates/index.html deleted file mode 100755 index b4b1621..0000000 --- a/snake_camera_vision_v2/templates/index.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - 🐍 SnakeCam Vision - - - - -

🐍 SnakeCam Vision

- -
- Live Video Feed -
-
-
-

-
- -

-

-
- -

-

-
- -

- -
- - - - diff --git a/vegeta_disk.sh.save b/vegeta_disk.sh.save deleted file mode 100755 index fd40910..0000000 --- a/vegeta_disk.sh.save +++ /dev/null @@ -1,4 +0,0 @@ - - - -