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

Allow detect.py to use video size for initial window size #8330

Merged
merged 3 commits into from
Jun 26, 2022
Merged

Allow detect.py to use video size for initial window size #8330

merged 3 commits into from
Jun 26, 2022

Conversation

NicholasZolton
Copy link
Contributor

@NicholasZolton NicholasZolton commented Jun 24, 2022

It appeared that there was a bug introduced in #8318 that caused the detect.py window to be opened with a smaller shape than the video content.

I have talked to @RyanHir (author of #8318) and the change introduced in the previous PR was unexpected. In the discussion held in #8318 it was claimed that namedWindow() had to be called in the loop, but this does not appear to be the case and can instead be called once.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhancements to visualization and efficiency in the YOLOv5 detection script.

📊 Key Changes

  • Initialized an empty list windows to keep track of created OpenCV windows.
  • Updated window creation logic to check if a window has already been created before initializing a new one.

🎯 Purpose & Impact

  • Avoid Redundancy: Prevents the unnecessary creation of multiple windows for the same output stream, which can clutter the screen and consume more system resources.
  • Optimize Viewing Experience: Ensures that each newly created OpenCV window is resized to match the dimensions of the output image, providing a more consistent and user-friendly display.
  • Impact to Users: Users will have a cleaner interface when running detection in real-time with the view enabled, leading to better performance and a more intuitive display of detection results.

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 @NicholasZolton, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with upstream/master. If your PR is behind upstream/master an automatic GitHub Actions merge may be attempted by writing /rebase in a new comment, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
# git checkout feature  # <--- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
  • ✅ Verify all Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." -Bruce Lee

@glenn-jocher
Copy link
Member

@NicholasZolton I can't test since neither this nor #8318 have any effect on macOS.

Does resizing the window to it's image size risk the possibility that the image is larger than the screen?

@RyanHir
Copy link
Contributor

RyanHir commented Jun 26, 2022

Hello, @NicholasZolton and I share a lab environment, and I am aware of the issue at hand.

Since we only develop on Ubuntu 20.04 systems, we have not tested if the issues we have are present on macOS or Windows. Before #8318, windows would open to show the full resolution image, but would not allow for resizing if the content was too big for the screen (Ubuntu). After the PR (#8318), all windows would open with a size similar to 300x300. This PR (#8330) is returning this functionality where the window will open to the "correct" size, but preserving the ability to resize.

@NicholasZolton
Copy link
Contributor Author

To further add to this, I just tested it on Windows and it appears that, just like MacOS, Windows isn't affected by any of these changes, so this PR (#8330) fixes the bug on Ubuntu and does not affect other platforms from what I can gather.

@glenn-jocher
Copy link
Member

@NicholasZolton @RyanHir got it, thanks guys!

@glenn-jocher glenn-jocher merged commit 0537e8d into ultralytics:master Jun 26, 2022
@glenn-jocher
Copy link
Member

@NicholasZolton PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
…s#8330)

* fixed initial window size of detect.py being tiny

* cleanup

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
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.

3 participants