Skip to content

Commit

Permalink
Merge pull request #1 from abhishek7kalra/linezonetrigger
Browse files Browse the repository at this point in the history
Linezonetrigger
  • Loading branch information
abhishek7kalra authored Oct 15, 2023
2 parents 9ded70c + bf725ef commit b1f8596
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion supervision/detection/line_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self, start: Point, end: Point):
self.tracker_state: Dict[str, bool] = {}
self.in_count: int = 0
self.out_count: int = 0
self.crossed = []

def trigger(self, detections: Detections):
"""
Expand All @@ -34,8 +35,13 @@ def trigger(self, detections: Detections):
Attributes:
detections (Detections): The detections for which to update the counts.
Returns:
np.ndarray: A boolean array indicating
which detection has crossed the line on the either sides
"""
for xyxy, _, confidence, class_id, tracker_id in detections:
self.crossed = [False] * len(detections)

for i, (xyxy, _, confidence, class_id, tracker_id) in enumerate(detections):
# handle detections with no tracker_id
if tracker_id is None:
continue
Expand Down Expand Up @@ -67,8 +73,13 @@ def trigger(self, detections: Detections):
self.tracker_state[tracker_id] = tracker_state
if tracker_state:
self.in_count += 1
self.crossed[i] = True

else:
self.out_count += 1
self.crossed[i] = True

return self.crossed


class LineZoneAnnotator:
Expand Down

0 comments on commit b1f8596

Please # to comment.