-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[LabelAnnotator, RichLabelAnnotator, VertexLabelAnnotator] - add smart label positioning #1383
Comments
Hey, @SkalskiP I'd like to try working on this. Could you provide any specific guidelines or tips for implementing this feature? |
We're opening this up to the community! @jeslinpjames, it's been a long time - are you still interested? I'll leave this open for a few days on the off-chance you're still around. Edit: Assigning to you temporarily until I hear back or a few days pass. |
With respect to the implementation details, I'm glad to see Piotr's plan as I had the exact same idea, down to the connector line.
Let's start with the simplest one:
An upgraded version of this would take into account both x and y axes of the overlap and allow arbitrary motion direction. Implement this if you wish, but take care to minimize motion - overemphasize the motion along the SMALLER overlap direction. An even more robust system uses some random noise to avoid stable states. We don't need this much detail 😉 find_smart_rectangle_positions(
xyxy: npt.NDarray[float], shape (H, W, 4).
region_boundary_wh: (float, float) # This is a hard boundary on the edges.
max_iterations=10: # return if there are no overlaps or this many iterations have passed.
force_multiplier=1.0 # Make the movements larger.
)
Whoever ends up working on this, I hope it gives you some ideas of how this could work! |
Contribution guidelinesIf you would like to make a contribution, please check that no one else is assigned already. Then leave a comment such as "Hi, I would like to work on this issue". We're happy to answer any questions about the task even if you choose not to contribute. Please share a Google Colab with minimal code to test the new feature. We know it's additional work, but it will speed up the review process. You may use the Starter Template. The reviewer must test each change. Setting up a local environment to do this is time-consuming. Please ensure that Google Colab can be accessed without any issues (make it public). Thank you! 🙏 |
I know this issue is already assigned to @jeslinpjames, but reading this:
I would like to work on this issue as well. |
Hi @kshitijaucharmal 👋 Indeed, I'm opening this up to the community. |
How's the task going? Do you have any updates for us? 😉 |
Yeah I have made some progress, specifically:
I still haven't gotten around to implementing it as an optional feature (using argument PS: Sorry its taking some time, my college exams are going on and I'm getting enough time for this :( |
All of that sounds like great progress. Very glad to hear that. Take your time! Our timeline is to have a PR for this next Friday. This way, I can pitch in the week after, in case the PR still needs some help 😉 |
Glad to hear that! I'll definitely raise a PR before Friday |
Description
Overlapping labels are a common issue, especially in crowded scenes. Let's add an optional smart label positioning feature to the
LabelAnnotator
,RichLabelAnnotator
, andVertexLabelAnnotator
that:The algorithm boils down to locating overlapping label boxes and then calculating the direction of vectors to push the labels apart. This process may require an iterative approach, as moving label boxes can lead to new overlaps with other label boxes.
Importantly, the bounding box remains in the same place, only the label boxes are moved. It would be great if, after the shift, the label and its original position were connected by a line.
Examples of incorrect behavior
Examples of expected behavior
vertex-label-annotator-v1-optimized.mp4
Here's the Google Colab I used to experiment with this feature.
Additional
The text was updated successfully, but these errors were encountered: