Spaces:
Running
Running
| import sys | |
| import os | |
| import json | |
| import numpy as np | |
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
| def test_queue_monitor(): | |
| print("Testing QueueMonitor...") | |
| try: | |
| try: | |
| import supervision | |
| except ImportError: | |
| print("⚠️ supervision module not installed. Skipping QueueMonitor test.") | |
| print(" Install with: pip install supervision") | |
| return True | |
| from queue_monitor import QueueMonitor | |
| monitor = QueueMonitor() | |
| dummy_frame = np.zeros((720, 1280, 3), dtype=np.uint8) | |
| polygon = np.array([[100, 100], [600, 100], [600, 600], [100, 600]]) | |
| monitor.setup_zones([polygon]) | |
| processed, stats = monitor.process_frame(dummy_frame) | |
| print(f"✅ QueueMonitor test passed. Stats: {stats}") | |
| return True | |
| except ImportError as e: | |
| print(f"⚠️ QueueMonitor test skipped due to missing dependency: {e}") | |
| print(" Install dependencies with: pip install -r requirements.txt") | |
| return True | |
| except Exception as e: | |
| print(f"❌ QueueMonitor test failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| return False | |
| if __name__ == "__main__": | |
| qm_success = test_queue_monitor() | |
| if qm_success: | |
| print("\n✅ Backend logic check completed successfully.") | |
| else: | |
| print("\n❌ Backend logic check failed.") | |
| sys.exit(1) | |