LineZoneAnnotator: Align text to line counter in non-horizontal lines #854
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In this pull request, I've enhanced
LineZoneAnnotator
class insupervision/detection/line_counter.py
to align text with theLineZone
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 thedraw_text
method insupervision/draw/utils.py.
Furthermore, users can now choose whether to draw the count centered in theLineZone
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.
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 asLineZoneAnnotator
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 newis_point_in_limits
method in theLineZone
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