Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jcruz-ferreyra
Copy link

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 jcruz-ferreyra changed the title LineZoneAnnotator: Align text to line coutner in non-horizontal lines LineZoneAnnotator: Align text to line counter in non-horizontal lines Feb 5, 2024
@SkalskiP
Copy link
Collaborator

SkalskiP commented Feb 7, 2024

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

@jcruz-ferreyra
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants