-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add BackgroundColorAnnotator #1385
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
Conversation
supervision/annotators/core.py
Outdated
@ensure_cv2_image_for_annotation | ||
def annotate(self, scene: ImageType, detections: Detections) -> ImageType: | ||
""" | ||
Annotates the given scene with masks based on the provided detections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's explain in more detail what happens. For folks relying on VSCode docs, this it the #1
most important place for documentation.
I'd like to know:
- what this does. (draws outside boxes and masks)
- how it treats
mask
andxyxy
(boxes).
I really like this one - it'd be a key component in a project idea I have. @capjamesg, I've made some comments. Could you also add a default image to the Colab? I'll do a deeper code review later on, but it generally looks okay. |
supervision/annotators/core.py
Outdated
) | ||
|
||
if detections.mask is None or self.force_box: | ||
for detection_idx in range(len(detections)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for x1, y1, x2, y2 in detections.xyxy.astype(int)
should work as well and be shorter.
Hi, @capjamesg 👋🏻 would you have time to respond to the comments above? |
Hey @capjamesg, Could we get an expanded Colab, please? Here's the tests I'd like to do:
Also, since I've seen different behaviours recently, it would be nice to check if both in-place and not in-place work on PIL images. You can use |
@LinasKo See my revisions to the Colab and code. |
Close, but to match the behaviour of annotators, it should work in-place for numpy images. I mean, it should modify the image you pass in: https://colab.research.google.com/drive/1SP4QyD_MgvWz9UI6qdkjAIaF74eRoUTy?usp=sharing Can you modify and return the same image the annotator gets as an argument, instead of returning a copy with Let me know if it gets too much - I'm a bit busy, but could help out 😉 |
@LinasKo / @capjamesg, what do you think about renaming it to |
Yesss, I like the new name much more |
@LinasKo which one? :) |
I misread; I thought you mentioned the previous one too.
|
@LinasKo, is there any chance you could propagate that name change in this PR? We wouldn't need to ask @capjamesg to work on it once again. |
On it. |
Okay, I can take this one over. The @capjamesg, thanks a lot! It's an awesome annotator to have in our toolbox. |
Changed the name, return type. Tested here: https://colab.research.google.com/drive/1SP4QyD_MgvWz9UI6qdkjAIaF74eRoUTy?usp=sharing |
Description
This PR adds a new
sv.BackgroundColorAnnotator
that highlights all regions outside of a list of bounding boxes or masks.Type of change
How has this change been tested, please provide a testcase or example of how you tested the change?
You can test this feature using the following Colab:
https://colab.research.google.com/drive/18GLw4TR-au9DUmAeWU30M7BFJ_00BlxO?usp=sharing
Any specific deployment considerations
N/A
Docs
N/A