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

Added labels to the drawing functions #93

Merged
merged 2 commits into from
Mar 11, 2022
Merged

Added labels to the drawing functions #93

merged 2 commits into from
Mar 11, 2022

Conversation

facundo-lezama
Copy link
Collaborator

@facundo-lezama facundo-lezama commented Mar 8, 2022

Now that Norfair allows to track multiple objects from different classes within a single Tracker object, the modifications added in this PR make it possible to draw labels both on detections and tracked objects. It also adds the possibility to color points and bounding boxes based on the labels so that objects from the same class have the same color.

Changes were made so that we keep backwards compatibility.

@facundo-lezama
Copy link
Collaborator Author

These are some examples of how it looks when drawing bounding boxes:

Screen Shot 2022-03-08 at 09 49 05

Screen Shot 2022-03-08 at 10 00 34

@facundo-lezama facundo-lezama marked this pull request as ready for review March 8, 2022 13:08
Copy link
Contributor

@joaqo joaqo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Almost ready to merge, just a couple of comments to discuss.

label_draw_position -= radius
cv2.putText(
frame,
f"Label: {d.label}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Label" string may occupy too much space when there are many objects on the image, it may make sense to make it shorter, or optional.

)
]
if draw_labels:
lines_to_draw.append("label:{}".format(obj.label))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to abbreviate 'label', as it takes too much space on the image.

@facundo-lezama facundo-lezama force-pushed the drawing-with-labels branch 3 times, most recently from fd74de3 to a070221 Compare March 10, 2022 18:42
Comment on lines 22 to 23
color_by_label: Optional[bool] = False,
draw_labels: Optional[bool] = False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't need to be optional, as optional would effectively let this variable have 3 states (true, false, None) but we only need 2.

Comment on lines 74 to 75
color_by_label: Optional[bool] = False,
draw_labels: Optional[bool] = False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment on lines 152 to 153
color_by_label: Optional[bool] = False,
draw_labels: Optional[bool] = False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@joaqo joaqo merged commit a6ba149 into master Mar 11, 2022
@joaqo joaqo deleted the drawing-with-labels branch March 11, 2022 18:41
javiber pushed a commit that referenced this pull request Sep 13, 2022
Added labels to the drawing functions
javiber pushed a commit that referenced this pull request Sep 13, 2022
Added labels to the drawing functions
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.

2 participants