File size: 1,626 Bytes
312fdff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
"""Print event counts from output.jsonl — compare with manual video counts."""
from __future__ import annotations

import json
import sys
from collections import Counter
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
DEFAULT = ROOT / "data" / "events" / "output.jsonl"


def main() -> None:
    path = Path(sys.argv[1]) if len(sys.argv) > 1 else DEFAULT
    if not path.exists():
        print(f"Missing {path}. Run the pipeline first.")
        sys.exit(1)

    by_type: Counter[str] = Counter()
    by_camera: Counter[str] = Counter()
    visitors: set[str] = set()
    staff_events = 0
    lines = 0

    for line in path.read_text(encoding="utf-8").splitlines():
        if not line.strip():
            continue
        lines += 1
        ev = json.loads(line)
        by_type[ev.get("event_type", "?")] += 1
        by_camera[ev.get("camera_id", "?")] += 1
        if ev.get("is_staff"):
            staff_events += 1
        else:
            visitors.add(ev.get("visitor_id", ""))

    print(f"File: {path}")
    print(f"Total events: {lines}")
    print(f"Unique visitors (non-staff): {len(visitors)}")
    print(f"Staff-tagged events: {staff_events}")
    print("\nBy event_type:")
    for k, v in sorted(by_type.items()):
        print(f"  {k}: {v}")
    print("\nBy camera_id:")
    for k, v in sorted(by_camera.items()):
        print(f"  {k}: {v}")
    print("\n--- Manual check ---")
    print("ENTRY count should be close to people entering on CAM 3 (entry camera).")
    print("Compare: open CAM 3.mp4 and count inbound crossings at the door.")


if __name__ == "__main__":
    main()