-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: #540 bug blur annotator #555
Conversation
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.
Hello there, thank you for opening an PR ! 🙏🏻 The team was notified and they will get back to you asap.
Refactored the `clip_boxes` function for clarity by renaming arguments from `boxes_xyxy` and `frame_resolution_wh` to `xyxy` and `resolution_wh`, respectively. These change makes the function arguments more intuitive and improves code readability. The processing of detections in `supervision/annotators/core.py` has been updated to include clipping of detection boxes to the image bounds before processing. This prevents errors and ensures detections beyond the image dimensions are handled correctly. Adjustments were also made in the test cases and in `polygon_zone.py` to match the updated `clip_boxes` function.
Hi, @fdloopes 👋🏻 Thanks a lot for the time you spent debugging. I decided to use the I tested the fix, and it works! Merging! Thanks a lot 🙏🏻 for providing test colabs. It made my life a lot easier. |
Hi @SkalskiP 👋🏻 Right, I didn't know about the existence of the clip_boxes function, but I followed the commits you made and got up to speed on it, it makes more sense to actually use it than the solution I implemented. Glad to have helped! 😃 |
Description
The coordinates of the detections object were found to have negative values in some cases, probably due to the trajectory prediction obtained with ByteTrack. Because of these negative coordinates, the ROI object was becoming null, which caused problems when calling cv2.blur(), as a valid array was expected.
The solution implemented for this bug was adjustment the command:
detections.xyxy[detection_idx].astype(int)
To:
np.maximum(detections.xyxy[detection_idx].astype(int), 0)
This way, whenever there is a negative coordinate, it will be mapped to 0.
Type of change
How has this change been tested, please provide a testcase or example of how you tested the change?
Google Colab Notebook: Example of the error occurring
Google Colab Notebook: Test with adjustment made
Any specific deployment considerations
I chose to make the adjustment within the BlurAnnotator.annotate() method because I imagine that in some scenarios ByteTrack returning negative coordinates may be interesting, such as multiple cameras and an object moving from one to another. However, this error may also occur for other annotators when using ByteTrack together.
I created two notebooks in colab, because after it imports a library it is not possible to make adjustments to it without resetting the environment, apparently it is preloaded in cache and the adjustments do not take effect.
Fix #540