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

Code before:
            ],
            [False, False, True, False, True, False, True, False],
            [False, True, False, True, False, True, False, True],
        ),
        (
            Vector(
                Point(0, 0),
                Point(-100, 0),
            ),
            [
                [-50, 70, -40, 50],
                [-50, -70, -40, -50],
                [-50, 70, -40, 50],
                [-50, -70, -40, -50],
                [-50, 70, -40, 50],
                [-50, -70, -40, -50],
                [-50, 70, -40, 50],
                [-50, -70, -40, -50],
            ],
            [False, False, True, False, True, False, True, False],
            [False, True, False, True, False, True, False, True],
        ),
    ],
)
def test_line_zone_single_detection(
    vector, bbox_sequence, expected_count_in: List[bool], expected_count_out: List[bool]
) -> None:
    line_zone = LineZone(start=vector.start, end=vector.end)
    for i, bbox in enumerate(bbox_sequence):
        detections = mock_detections(
            xyxy=[bbox],
            tracker_id=[0],
        )
        count_in, count_out = line_zone.trigger(detections)
        assert count_in[0] == expected_count_in[i]
        assert count_out[0] == expected_count_out[i]
        assert line_zone.in_count == sum(expected_count_in[: (i + 1)])
        assert line_zone.out_count == sum(expected_count_out[: (i + 1)])


@pytest.mark.parametrize(
    "vector, bbox_sequence, expected_count_in, expected_count_out, crossing_anchors",
    [
        (
            Vector(
                Point(0, 0),
                Point(100, 100),
            ),
            [
                [50, 30, 60, 20],
                [20, 50, 40, 30],

Review comment (suggestion):
Once again, please rename `expected_count_in` and `expected_count_out` to `expected_crossed_in` and `expected_crossed_out` respectively.

Code after:
                [-4 + 20, -6, -2 + 20, -4],
                [-4, -6, -2, -4],
                [-4 + 20, -6, -2 + 20, -4],
            ],
            [False, False, False, False],
            [False, False, False, False],
        ),
        (  # Move into line partway
            Vector(Point(0, 0), Point(10, 0)),
            [
                [4, 4, 6, 6],
                [4 + 5, 4, 6 + 5, 6],
                [4, 4, 6, 6],
                [4 + 5, 4, 6 + 5, 6],
            ],
            [False, False, False, False],
            [False, False, False, False],
        ),
        (  # V-shaped crossing from outside limits - not supported.
            Vector(Point(0, 0), Point(10, 0)),
            [[-3, 6, -1, 8], [4, -6, 6, -4], [11, 6, 13, 8]],
            [False, False, False],
            [False, False, False],
        ),
        (  # Diagonal movement, from within limits to outside - not supported
            Vector(Point(0, 0), Point(10, 0)),
            [[4, 1, 6, 3], [11, 1 - 20, 13, 3 - 20]],
            [False, False],
            [False, False],
        ),
        (  # Diagonal movement, from outside limits to within - not supported
            Vector(Point(0, 0), Point(10, 0)),
            [
                [11, 21, 13, 23],
                [4, -3, 6, -1],
            ],
            [False, False],
            [False, False],
        ),
        (  # Diagonal crossing, from outside to outside limits - not supported.
            Vector(Point(0, 0), Point(10, 0)),
            [
                [-4, 4, -2, 8],
                [-4 + 16, -4, -2 + 16, -6],
                [-4, 4, -2, 8],
                [-4 + 16, -4, -2 + 16, -6],
            ],
            [False, False, False, False],
            [False, False, False, False],
        ),
    ],