v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
118
examples/test_screen_capturer.py
Normal file
118
examples/test_screen_capturer.py
Normal file
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test simple du ScreenCapturer
|
||||
Vérifie que la capture d'écran fonctionne correctement
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Ajouter le chemin du projet
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from core.capture.screen_capturer import ScreenCapturer
|
||||
import numpy as np
|
||||
|
||||
|
||||
def test_screen_capturer():
|
||||
"""Test du ScreenCapturer"""
|
||||
print("\n" + "="*60)
|
||||
print("TEST DU SCREEN CAPTURER")
|
||||
print("="*60)
|
||||
|
||||
# 1. Initialisation
|
||||
print("\n1. Initialisation...")
|
||||
try:
|
||||
capturer = ScreenCapturer()
|
||||
print(f" ✓ Méthode utilisée: {capturer.method}")
|
||||
except Exception as e:
|
||||
print(f" ✗ Erreur d'initialisation: {e}")
|
||||
return False
|
||||
|
||||
# 2. Capture d'écran
|
||||
print("\n2. Capture d'écran...")
|
||||
try:
|
||||
img = capturer.capture()
|
||||
|
||||
if img is None:
|
||||
print(" ✗ Capture a retourné None")
|
||||
return False
|
||||
|
||||
if not isinstance(img, np.ndarray):
|
||||
print(f" ✗ Type incorrect: {type(img)}")
|
||||
return False
|
||||
|
||||
print(f" ✓ Image capturée: {img.shape}")
|
||||
print(f" ✓ Type: {img.dtype}")
|
||||
print(f" ✓ Taille: {img.nbytes / 1024 / 1024:.2f} MB")
|
||||
|
||||
# Vérifier les dimensions
|
||||
if len(img.shape) != 3:
|
||||
print(f" ✗ Dimensions incorrectes: {img.shape}")
|
||||
return False
|
||||
|
||||
if img.shape[2] != 3:
|
||||
print(f" ✗ Nombre de canaux incorrect: {img.shape[2]}")
|
||||
return False
|
||||
|
||||
print(f" ✓ Format RGB valide")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ✗ Erreur de capture: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
# 3. Fenêtre active
|
||||
print("\n3. Détection de fenêtre active...")
|
||||
try:
|
||||
window = capturer.get_active_window()
|
||||
|
||||
if window:
|
||||
print(f" ✓ Fenêtre active: {window['title']}")
|
||||
print(f" ✓ Position: ({window['x']}, {window['y']})")
|
||||
print(f" ✓ Taille: {window['width']}x{window['height']}")
|
||||
else:
|
||||
print(" ⚠ Aucune fenêtre active détectée (normal sur certains systèmes)")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ⚠ Erreur de détection de fenêtre: {e}")
|
||||
|
||||
# 4. Captures multiples
|
||||
print("\n4. Test de captures multiples...")
|
||||
try:
|
||||
for i in range(3):
|
||||
img = capturer.capture()
|
||||
if img is None:
|
||||
print(f" ✗ Capture {i+1} a échoué")
|
||||
return False
|
||||
print(f" ✓ Capture {i+1}: {img.shape}")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ✗ Erreur lors des captures multiples: {e}")
|
||||
return False
|
||||
|
||||
# 5. Sauvegarde d'un exemple
|
||||
print("\n5. Sauvegarde d'un exemple...")
|
||||
try:
|
||||
from PIL import Image
|
||||
|
||||
img_pil = Image.fromarray(img)
|
||||
output_path = Path(__file__).parent / "test_capture_output.png"
|
||||
img_pil.save(output_path)
|
||||
|
||||
print(f" ✓ Image sauvegardée: {output_path}")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ⚠ Impossible de sauvegarder: {e}")
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("✅ TOUS LES TESTS RÉUSSIS")
|
||||
print("="*60)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_screen_capturer()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user