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

Code before:
                for anchor in anchors:
                    if not self.is_point_in_line_range(anchor):
                        all_anchors_in_range = False
                        break

                if not all_anchors_in_range:
                    continue

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

            return self.in_count, self.out_count

        elif self.count_condition == "center_point_crossed":
            for i, (xyxy, _, confidence, class_id, tracker_id) in enumerate(detections):
                if tracker_id is None:
                    continue

                x1, y1, x2, y2 = xyxy

                # Calculate the center point of the box
                center_point = Point(x=(x1 + x2) / 2, y=(y1 + y2) / 2)

                current_state = self.vector.cross_product(center_point)

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

                previous_state = self.tracker_state[tracker_id]

                # Update the tracker state and check for crossing
                if previous_state * current_state < 0 and self.is_point_in_line_range(
                    center_point
                ):
                    self.tracker_state[tracker_id] = current_state
                    if current_state > 0:
                        self.in_count += 1
                        crossed_in[i] = True
                    elif current_state < 0:
                        self.out_count += 1
                        crossed_out[i] = True

            return self.in_count, self.out_count


class LineZoneAnnotator:

Review comment (suggestion):
Let's not limit ourselves to just the center of the box. Let's make it more general. Also, you can use [`get_anchors_coordinates`](https://github.com/roboflow/supervision/blob/64661a3e4aae2830a37cc277ec2d73c9dee0ee1c/supervision/detection/core.py#L760) to calculate coordinates of specific bounding box points. (already tested with multiple unit tests)

Code after:
            if not in_limits:
                continue

            triggers = [
                self.vector.cross_product(point=anchor) > 0 for anchor in box_anchors
            ]

            if len(set(triggers)) == 2:
                continue

            tracker_state = triggers[0]

            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:
    def __init__(
        self,
        thickness: float = 2,
        color: Color = Color.white(),
        text_thickness: float = 2,
        text_color: Color = Color.black(),
        text_scale: float = 0.5,
        text_offset: float = 1.5,
        text_padding: int = 10,
        custom_in_text: Optional[str] = None,
        custom_out_text: Optional[str] = None,
    ):
        """
        Initialize the LineCounterAnnotator object with default values.

        Attributes:
            thickness (float): The thickness of the line that will be drawn.
            color (Color): The color of the line that will be drawn.
            text_thickness (float): The thickness of the text that will be drawn.
            text_color (Color): The color of the text that will be drawn.