[go: nahoru, domu]

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

fix: #540 bug blur annotator #555

Merged
merged 4 commits into from
Oct 31, 2023

Conversation

fdloopes
Copy link
@fdloopes fdloopes commented Oct 31, 2023

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

  • Bug fix (non-breaking change which fixes an issue)

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

Copy link
Contributor
@github-actions github-actions bot left a 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.

@CLAassistant
Copy link
CLAassistant commented Oct 31, 2023

CLA assistant check
All committers have signed the CLA.

@onuralpszr onuralpszr changed the title 540 bug blur annotator #540 bug blur annotator Oct 31, 2023
@onuralpszr onuralpszr changed the title #540 bug blur annotator fix: #540 bug blur annotator Oct 31, 2023
SkalskiP and others added 2 commits October 31, 2023 18:04
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.
@SkalskiP SkalskiP added bug Something isn't working api:annotator Annotators labels Oct 31, 2023
@SkalskiP SkalskiP self-assigned this Oct 31, 2023
@SkalskiP
Copy link
Collaborator
SkalskiP commented Oct 31, 2023

Hi, @fdloopes 👋🏻 Thanks a lot for the time you spent debugging. I decided to use the clip_boxes function that we already have in Supervision. It works just like your fix but ensures boxes are clipped to 0 and to frame width and height.

I tested the fix, and it works! Merging!

Thanks a lot 🙏🏻 for providing test colabs. It made my life a lot easier.

@SkalskiP SkalskiP merged commit 92592c8 into roboflow:develop Oct 31, 2023
6 checks passed
@fdloopes
Copy link
Author

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! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:annotator Annotators bug Something isn't working
Projects
Status: Current Release: Done
Development

Successfully merging this pull request may close these issues.

BlurAnnotator raise (-215:Assertion failed) !_src.empty() in function 'boxFilter' error
3 participants