TobiasLogic commited on
Commit
4bc49a3
·
verified ·
1 Parent(s): e13bc33

Add restricted zone detection module and demo

Browse files
Files changed (1) hide show
  1. README.md +39 -0
README.md CHANGED
@@ -121,6 +121,45 @@ occasionally hallucinates objects on plain background surfaces, reading a suppor
121
  detection quality on out-of-domain footage (camera angles, lighting, and compression that COCO's
122
  photos do not really cover) is visibly weaker than on COCO's own validation images.
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  ## Architecture
125
 
126
  ```text
 
121
  detection quality on out-of-domain footage (camera angles, lighting, and compression that COCO's
122
  photos do not really cover) is visibly weaker than on COCO's own validation images.
123
 
124
+ ## Restricted Zone Detection
125
+
126
+ <img src="assets/zone_demo.gif" alt="A marked polygon zone over a plaza walkway, with tracked people highlighted and a red ALERT banner firing when someone enters the zone" width="420">
127
+
128
+ [Full-length video (20s, MP4)](assets/zone_demo.mp4)
129
+
130
+ A small layer on top of the tracker: `src/objectmodel_v1/zones.py` defines a polygon in the same
131
+ pixel coordinates as the tracked boxes, and fires an event only on the transition into or out of
132
+ it, not on every frame a track spends inside. It keys off each box's bottom-center point (roughly
133
+ where feet touch the ground) rather than the box centroid, since a zone drawn on a floor plane
134
+ should care where someone is standing, not where their torso is.
135
+
136
+ Correctness is checked on a synthetic sequence, not just eyeballed on video: a track walking
137
+ through a rectangle produces exactly one `entered` and one `exited` event, none of the frames
138
+ spent inside re-fire, a track that never enters never fires, and a fresh id gets independent
139
+ state. That test lives with the module.
140
+
141
+ On the same plaza clip used above, the zone above the walkway fired 91 enter/exit events over 20
142
+ seconds. Read that number carefully: most of it is not 91 different real crossings. It is the
143
+ same tracker id churn already described in the section above, the same person's track resetting
144
+ and re-entering the zone as a "new" id, plus a handful of misclassified objects (a backpack or
145
+ handbag read as its own tracked object) that shouldn't have triggered an event at all. The event
146
+ mechanics are verified correct; the real-world event count is exactly as reliable as the
147
+ underlying detector and tracker are, which right now is "usable for a demo, not for anything
148
+ where a false alert has a real cost."
149
+
150
+ ```python
151
+ from objectmodel_v1.zones import RestrictedZoneMonitor
152
+
153
+ zone = [(300, 150), (650, 150), (650, 320), (300, 320)] # pixel-space polygon
154
+ monitor = RestrictedZoneMonitor(zone)
155
+
156
+ for frame_index, frame in enumerate(video_frames):
157
+ boxes, labels, scores = detect(frame)
158
+ tracks = tracker.update(boxes, labels, scores)
159
+ for event in monitor.update(tracks, frame_index):
160
+ print(event.track_id, event.kind, event.position) # "entered" or "exited"
161
+ ```
162
+
163
  ## Architecture
164
 
165
  ```text