Repository: roboflow/supervision
File: supervision/detection/line_zone.py (Python)

Code before:
                "Line zone counting skipped. LineZone requires tracker_id. Refer to "
                "https://supervision.roboflow.com/latest/trackers for more "
                "information.",
                category=SupervisionWarnings,
            )
            return crossed_in, crossed_out

        all_anchors = np.array(
            [
                detections.get_anchors_coordinates(anchor)
                for anchor in self.triggering_anchors
            ]
        )

        cross_products_1 = self._cross_product(all_anchors, self.limits[0])
        cross_products_2 = self._cross_product(all_anchors, self.limits[1])
        # anchor is in limits if it's on the same side of both limit vectors
        in_limits = ~np.logical_xor(cross_products_1 > 0, cross_products_2 > 0)
        # Reduce array to find out if all anchors for a detection are within limits
        in_limits = np.min(in_limits, axis=0)

        # Calculate which anchors lie to the left of the line
        triggers = self._cross_product(all_anchors, self.vector) < 0
        # Reduce to find out if all anchors for a
        # detection lie to the left (or right) of the line
        max_triggers = np.max(triggers, axis=0)
        min_triggers = np.min(triggers, axis=0)
        for i, tracker_id in enumerate(detections.tracker_id):
            if not in_limits[i]:
                continue

            if min_triggers[i] != max_triggers[i]:
                # One anchor lies to the left of the line
                # whilst another lies to the right
                continue

            tracker_state = max_triggers[i]
            if tracker_id not in self.tracker_state:
                self.tracker_state[tracker_id] = tracker_state
                continue

            if self.tracker_state.get(tracker_id) == tracker_state:
                continue

            self.tracker_state[tracker_id] = tracker_state
            if tracker_state:
                self.in_count += 1
                crossed_in[i] = True
            else:
                self.out_count += 1
                crossed_out[i] = True

Review comment (suggestion):
@tc360950 what do you think about calculating this slightly differently, but at the same time naming variables in a more descriptive way:

```python
has_any_left_trigger = np.any(triggers, axis=1)
has_any_right_trigger = np.any(~triggers, axis=1)
is_uniformly_triggered = ~(has_any_left_trigger & has_any_right_trigger)
```

I don't have a particularly strong opinion on this. If you think it's better to stick with your names, we can merge.

Code after:
            warnings.warn(
                "Line zone counting skipped. LineZone requires tracker_id. Refer to "
                "https://supervision.roboflow.com/latest/trackers for more "
                "information.",
                category=SupervisionWarnings,
            )
            return crossed_in, crossed_out

        all_anchors = np.array(
            [
                detections.get_anchors_coordinates(anchor)
                for anchor in self.triggering_anchors
            ]
        )

        cross_products_1 = cross_product(all_anchors, self.limits[0])
        cross_products_2 = cross_product(all_anchors, self.limits[1])
        in_limits = (cross_products_1 > 0) == (cross_products_2 > 0)
        in_limits = np.all(in_limits, axis=0)

        triggers = cross_product(all_anchors, self.vector) < 0
        has_any_left_trigger = np.any(triggers, axis=0)
        has_any_right_trigger = np.any(~triggers, axis=0)
        is_uniformly_triggered = ~(has_any_left_trigger & has_any_right_trigger)
        for i, tracker_id in enumerate(detections.tracker_id):
            if not in_limits[i]:
                continue

            if not is_uniformly_triggered[i]:
                continue

            tracker_state = has_any_left_trigger[i]
            if tracker_id not in self.tracker_state:
                self.tracker_state[tracker_id] = tracker_state
                continue

            if self.tracker_state.get(tracker_id) == tracker_state:
                continue

            self.tracker_state[tracker_id] = tracker_state
            if tracker_state:
                self.in_count += 1
                crossed_in[i] = True
            else:
                self.out_count += 1
                crossed_out[i] = True

        return crossed_in, crossed_out


class LineZoneAnnotator: