Files
rpa_vision_v3/examples/create_test_screenshot.py
Dom a27b74cf22 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>
2026-01-29 11:23:51 +01:00

135 lines
5.1 KiB
Python

#!/usr/bin/env python3
"""
Créer un screenshot de test réaliste pour la détection VLM
"""
from PIL import Image, ImageDraw, ImageFont
import sys
from pathlib import Path
def create_realistic_ui_screenshot(output_path: str = "test_ui_screenshot.png"):
"""Créer un screenshot UI réaliste"""
# Créer une image plus grande et réaliste
width, height = 1200, 800
img = Image.new('RGB', (width, height), color='#f0f0f0')
draw = ImageDraw.Draw(img)
# Essayer de charger une police, sinon utiliser la police par défaut
try:
font_large = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
font_medium = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 16)
font_small = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
except:
font_large = ImageFont.load_default()
font_medium = ImageFont.load_default()
font_small = ImageFont.load_default()
# Barre de titre
draw.rectangle([0, 0, width, 60], fill='#2c3e50')
draw.text((20, 20), "Application Demo", fill='white', font=font_large)
# Menu bar
draw.rectangle([0, 60, width, 100], fill='#34495e')
menu_items = ["File", "Edit", "View", "Help"]
x_pos = 20
for item in menu_items:
draw.text((x_pos, 70), item, fill='white', font=font_medium)
x_pos += 100
# Sidebar
draw.rectangle([0, 100, 250, height], fill='#ecf0f1')
draw.text((20, 120), "Navigation", fill='#2c3e50', font=font_large)
# Sidebar buttons
sidebar_items = [
("Dashboard", 160),
("Users", 210),
("Settings", 260),
("Reports", 310),
("Logout", 360)
]
for item, y in sidebar_items:
# Button background
draw.rectangle([20, y, 230, y + 35], fill='white', outline='#bdc3c7', width=2)
draw.text((30, y + 8), item, fill='#2c3e50', font=font_medium)
# Main content area
draw.rectangle([250, 100, width, height], fill='white')
# Form title
draw.text((300, 130), "User Registration Form", fill='#2c3e50', font=font_large)
# Form fields
form_y = 180
# Name field
draw.text((300, form_y), "Name:", fill='#2c3e50', font=font_medium)
draw.rectangle([300, form_y + 30, 700, form_y + 65], fill='white', outline='#bdc3c7', width=2)
draw.text((310, form_y + 38), "Enter your name...", fill='#95a5a6', font=font_small)
# Email field
form_y += 100
draw.text((300, form_y), "Email:", fill='#2c3e50', font=font_medium)
draw.rectangle([300, form_y + 30, 700, form_y + 65], fill='white', outline='#bdc3c7', width=2)
draw.text((310, form_y + 38), "your.email@example.com", fill='#95a5a6', font=font_small)
# Password field
form_y += 100
draw.text((300, form_y), "Password:", fill='#2c3e50', font=font_medium)
draw.rectangle([300, form_y + 30, 700, form_y + 65], fill='white', outline='#bdc3c7', width=2)
draw.text((310, form_y + 38), "••••••••", fill='#2c3e50', font=font_small)
# Checkboxes
form_y += 100
# Remember me checkbox
draw.rectangle([300, form_y, 325, form_y + 25], fill='white', outline='#3498db', width=2)
draw.line([305, form_y + 12, 312, form_y + 20], fill='#3498db', width=3)
draw.line([312, form_y + 20, 320, form_y + 5], fill='#3498db', width=3)
draw.text((335, form_y + 3), "Remember me", fill='#2c3e50', font=font_medium)
# Terms checkbox
draw.rectangle([300, form_y + 40, 325, form_y + 65], fill='white', outline='#bdc3c7', width=2)
draw.text((335, form_y + 43), "I accept the terms and conditions", fill='#2c3e50', font=font_medium)
# Buttons
form_y += 120
# Submit button (primary)
draw.rectangle([300, form_y, 450, form_y + 50], fill='#3498db', outline='#2980b9', width=2)
draw.text((350, form_y + 15), "Submit", fill='white', font=font_large)
# Cancel button
draw.rectangle([470, form_y, 620, form_y + 50], fill='#95a5a6', outline='#7f8c8d', width=2)
draw.text((520, form_y + 15), "Cancel", fill='white', font=font_large)
# Reset button
draw.rectangle([640, form_y, 790, form_y + 50], fill='white', outline='#bdc3c7', width=2)
draw.text((695, form_y + 15), "Reset", fill='#2c3e50', font=font_large)
# Footer
draw.rectangle([0, height - 40, width, height], fill='#34495e')
draw.text((20, height - 28), "© 2024 Demo Application", fill='white', font=font_small)
draw.text((width - 200, height - 28), "Version 1.0.0", fill='white', font=font_small)
# Sauvegarder
img.save(output_path)
print(f"✓ Screenshot créé: {output_path}")
print(f" Dimensions: {width}x{height}")
print(f" Éléments UI inclus:")
print(f" - Barre de titre")
print(f" - Menu (4 items)")
print(f" - Sidebar (5 boutons)")
print(f" - Formulaire (3 champs de texte)")
print(f" - Checkboxes (2)")
print(f" - Boutons d'action (3)")
return output_path
if __name__ == "__main__":
output = sys.argv[1] if len(sys.argv) > 1 else "test_ui_screenshot.png"
create_realistic_ui_screenshot(output)