Count each person just once
just once and either in or out
This commit is contained in:
parent
91f4d70a77
commit
40ce7946d5
1 changed files with 8 additions and 3 deletions
|
|
@ -22,15 +22,20 @@ class Counter:
|
||||||
)
|
)
|
||||||
|
|
||||||
if track_id not in self.track_memory:
|
if track_id not in self.track_memory:
|
||||||
self.track_memory[track_id] = center
|
self.track_memory[track_id] = [center, False]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
prev = self.track_memory[track_id]
|
prev = self.track_memory[track_id][0]
|
||||||
self.track_memory[track_id] = center
|
self.track_memory[track_id][0] = center
|
||||||
|
|
||||||
|
if self.track_memory[track_id][1]:
|
||||||
|
continue
|
||||||
|
|
||||||
if prev < line_position <= center:
|
if prev < line_position <= center:
|
||||||
self.in_count += 1
|
self.in_count += 1
|
||||||
self.metrics["people_in"].labels(stream=self.stream_id).inc()
|
self.metrics["people_in"].labels(stream=self.stream_id).inc()
|
||||||
|
self.track_memory[track_id][1] = True
|
||||||
elif prev > line_position >= center:
|
elif prev > line_position >= center:
|
||||||
self.out_count += 1
|
self.out_count += 1
|
||||||
self.metrics["people_out"].labels(stream=self.stream_id).inc()
|
self.metrics["people_out"].labels(stream=self.stream_id).inc()
|
||||||
|
self.track_memory[track_id][1] = True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue