supervision icon indicating copy to clipboard operation
supervision copied to clipboard

LineZoneAnnotator: Align text to line counter in non-horizontal lines

Open jcruz-ferreyra opened this issue 5 months ago • 3 comments

Description

In this pull request, I've enhanced LineZoneAnnotator class in supervision/detection/line_counter.py to align text with the LineZone object even when it is non-horizontal.

Additionally, I've introduced the option to omit drawing the text box behind the text, leveraging the optional condition on the background_color attribute in the draw_text method in supervision/draw/utils.py. Furthermore, users can now choose whether to draw the count centered in the LineZone object or aligned with its end, offering a solution to prevent overlaps in case of multiple LineZone objects in the same frame.

Type of change

Please delete options that are not relevant.

  • [ ] New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

You can explore the results of the changes made in this Colab notebook. I've tested LineZone objects with varying orientations and positions within the frame, as well as LineZoneAnnotator objects with different values for draw_text_box and draw_centered parameters.

NOTE: Personally, I don't fully like the circles drawn at the extremes of the LineZone objects. However, I chose not to modify them to maintain conciseness in the pull request. Given the introduction of the new is_point_in_limits method in the LineZone class, it might be more effective to draw a small line perpendicular to the main line (or even nothing at all) to emphasize this new functionality.

Any specific deployment considerations

No specific deployment considerations. Just one parameter added as an attribute for LineZone Class with default value "both" mantaining previous implementation.

Docs

No changes made to Docs

jcruz-ferreyra avatar Feb 05 '24 14:02 jcruz-ferreyra

Hi @jcruz-ferreyra 👋🏻 Thanks a lot of opening the new PR.

SkalskiP avatar Feb 07 '24 08:02 SkalskiP

Hi @SkalskiP! I was wondering if you've been able to check the PR

jcruz-ferreyra avatar Feb 16 '24 18:02 jcruz-ferreyra