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 preview resize in detect.py #8318

Merged
merged 4 commits into from
Jun 24, 2022

Conversation

RyanHir
Copy link
Contributor

@RyanHir RyanHir commented Jun 23, 2022

This change is purely visual. Currently when running the detect.py script with a high resolution video, it will open a preview windows which may be bigger than the screen that the content is being viewed on. This PR is simply resizing the content after annotation if the user requests the preview to be resized. This PR will allow for the preview to be resized by dragging.

Tested on Ubuntu 20.04

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhanced display flexibility during image detection in YOLOv5.

📊 Key Changes

  • Added a new line in the detect.py script that enables window resizing for image displays on Linux systems.

🎯 Purpose & Impact

  • The purpose of the change is to improve user experience on Linux by allowing them to resize the detection result windows to their preference.
  • Users now have better control over how they view detection outputs, which can be especially beneficial when working with images of varying sizes or when multitasking on their screens. 🖥️🔍

@RyanHir RyanHir changed the title Add --viewsz to detect.py Allow preview resize in detect.py Jun 23, 2022
@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 24, 2022

@RyanHir thanks for the PR! If windows are exceeding screen size then the simplest solution would be to constrain show sizes to screen sizes while maintaining aspect ratio.

It's preferable to automatically solve problems rather than introducing additional parameters that can manually solve them. Can you update this PR to:

  1. Implement this screen-size check and resize on check fail
  2. Remove the manual argument?

Thanks!

@RyanHir
Copy link
Contributor Author

RyanHir commented Jun 24, 2022

Hello @glenn-jocher , in the original commit i added a new parameter to change the window size. However i removed this shortly after as i realized you can tell OpenCV to allow user resize events. Please look at the changes in the latest commit as it is a single line change.

@glenn-jocher
Copy link
Member

@RyanHir oh nice, very minimal. Is this suitable for running multiple times though, i.e. for a webcam do we want this line to run 30 times per second?

@RyanHir
Copy link
Contributor Author

RyanHir commented Jun 24, 2022

I do not believe this to cause frame rate issues as the drawing to screen is handled by the underlying system libraries. However, I have not tested for performance loss.

@RyanHir
Copy link
Contributor Author

RyanHir commented Jun 24, 2022

As for the call running multiple times, from what I read this is required for OpenCV.

@glenn-jocher
Copy link
Member

@RyanHir tested on macOS, saw no difference in speed or functionality (can resize window with master already).

On Ubuntu it's the case that master can't resize the window but with PR you can?

@RyanHir
Copy link
Contributor Author

RyanHir commented Jun 24, 2022

Correct. Resizing is disabled by default from what I have seen.

@glenn-jocher
Copy link
Member

@RyanHir ok got it! Thanks for the feedback!

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

@glenn-jocher glenn-jocher merged commit 19f33cb into ultralytics:master Jun 24, 2022
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Initial implementation of --viewsz

* use mouse resize

* Add comment

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.

2 participants