{"record":{"id":"445d907b7da4282b","repo":"roboflow/supervision","slug":"triggering-anchors-cannot-be-empty","errorCode":null,"errorMessage":"Triggering anchors cannot be empty.","messagePattern":"Triggering anchors cannot be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/line_zone.py","lineNumber":129,"sourceCode":"                crossed the line. This is useful when dealing with unstable\n                bounding boxes or when detections may linger on the line.\n        \"\"\"\n        self.vector = Vector(start=start, end=end)\n        self.limits = self._calculate_region_of_interest_limits(vector=self.vector)\n        self.crossing_history_length = max(2, minimum_crossing_threshold + 1)\n        self.crossing_state_history: dict[int, deque[bool]] = defaultdict(\n            lambda: deque(maxlen=self.crossing_history_length)\n        )\n        # Tracks consecutive frames a tracker key has been absent; eviction\n        # requires crossing_history_length absent frames so that ByteTrack\n        # coasting gaps (single-frame detection drops) don't reset mid-crossing\n        # state prematurely.\n        self._tracker_frames_absent: dict[int, int] = {}\n        self._in_count_per_class: Counter[int | None] = Counter()\n        self._out_count_per_class: Counter[int | None] = Counter()\n        self.triggering_anchors = triggering_anchors\n        if not list(self.triggering_anchors):\n            raise ValueError(\"Triggering anchors cannot be empty.\")\n        self.class_id_to_name: dict[int, str] = {}\n\n    @property\n    def in_count(self) -> int:\n        return sum(self._in_count_per_class.values())\n\n    @property\n    def out_count(self) -> int:\n        return sum(self._out_count_per_class.values())\n\n    @property\n    def in_count_per_class(self) -> dict[int | None, int]:\n        return dict(self._in_count_per_class)\n\n    @property\n    def out_count_per_class(self) -> dict[int | None, int]:\n        return dict(self._out_count_per_class)\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/line_zone.py#L111-L147","documentation":"LineZone's constructor validates that the triggering_anchors iterable is non-empty; an empty sequence means no keypoint could ever cross the line, so counting would silently produce zeros forever. The library prefers failing fast at construction over a useless-but-quiet tracker.","triggerScenarios":"Constructing sv.LineZone(start=..., end=..., triggering_anchors=[]) — e.g. passing an empty list literal, an anchors selection computed from a pose model with zero keypoints, or a variable that was filtered down to nothing (like [k for k in range(17) if k in selected] with an empty selected set).","commonSituations":"Building triggering_anchors dynamically from a per-model keypoint list that is empty for the chosen model; refactoring from hardcoded anchors (e.g. [sv.Position.CENTER]) to computed ones; copy-paste from an example where the anchors list was deleted.","solutions":["Pass at least one anchor, most commonly sv.Position.CENTER or an index list like [0, 1] for pose keypoints.","If anchors come from a pose config, assert the selection is non-empty before constructing LineZone.","Default to [sv.Position.CENTER] when your detection has no keypoints."],"exampleFix":"# before\n zone = sv.LineZone(start=start, end=end, triggering_anchors=[])\n\n# after\n zone = sv.LineZone(start=start, end=end, triggering_anchors=[sv.Position.CENTER])","handlingStrategy":"validation","validationCode":"anchors = [a for a in requested_anchors if a is not None]\nif not anchors:\n    anchors = [sv.Position.CENTER]\nzone = sv.LineZone(start=start, end=end, triggering_anchors=anchors)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute anchor lists from a named constant, never inline filters that can empty.","Unit-test zone construction with your production anchor configuration.","Default to [sv.Position.CENTER] when keypoints are unavailable."],"tags":["line-zone","validation","constructor","anchors"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}