Skip to content

[LineZone] - allow per class counting  #790

@SkalskiP

Description

@SkalskiP

Description

Currently, sv.LineZone provides only aggregated counts - all classes are thrown into one bucket. In the past, many users have asked us to provide more granular - per class count. This can be achieved by adding class_in_count and class_out_count dictionaries that will store per-class counts.

API

class LineZone:

    def __init__(
        self,
        start: Point,
        end: Point,
        triggering_anchors: Iterable[Position] = (
            Position.TOP_LEFT,
            Position.TOP_RIGHT,
            Position.BOTTOM_LEFT,
            Position.BOTTOM_RIGHT,
        ),
    ):
        # Existing initialization code...

        self.class_in_count: Dict[int, int] = {}
        self.class_out_count: Dict[int, int] = {}

    def trigger(self, detections: Detections) -> Tuple[np.ndarray, np.ndarray]:
        crossed_in = np.full(len(detections), False)
        crossed_out = np.full(len(detections), False)

        # Required logic changes...

Additional

  • Note: Please share a Google Colab with minimal code to test the new feature. We know it's additional work, but it will definitely speed up the review process. Each change must be tested by the reviewer. Setting up a local environment to do this is time-consuming. Please ensure that Google Colab can be accessed without any issues (make it public). Thank you! 🙏🏻

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions