File size: 1,456 Bytes
ad1bda5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)