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

Add --source screen for screenshot inference #9542

Merged
merged 24 commits into from
Sep 22, 2022

Conversation

zombob
Copy link
Contributor

@zombob zombob commented Sep 22, 2022

add SCREENSHOT as source (isse link)
you can use it like:

python .\detect.py --source screen   # default full screen(0)
python .\detect.py --source "screen 2"   # 2nd screen only if you have multiple monitors, can specify screen number
python .\detect.py --source "screen 500 600 256 256"   # Specify top, left, width and height
python .\detect.py --source "screen 1 500 100 256 256"   # Specify screen nunmber, top, left, width and height

Position parameters(left,top) is relative to the "screen"'s left and top,
if you have multiple monitors, the left and top of the screen my be NOT (0,0) !
About the screen can refer to the mss document

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Introducing screenshot detection to YOLOv5 with the new screen source option.

📊 Key Changes

  • 🖥️ Added ability to take screenshots as input with screen source keyword.
  • 🔎 Expanded input sources in README.md, notebook, and script help strings to include new screenshot functionality.
  • 🧰 Integrated the LoadScreenshots class for fetching screen captures as a data source.
  • ➕ Added a requirement for the mss library, which is necessary for screenshot functionality.

🎯 Purpose & Impact

  • 🆕 The purpose of this change is to widen the input capabilities of YOLOv5 to include live screen captures, offering more flexibility for real-time applications.
  • 📈 This will have a positive impact on users who wish to apply YOLOv5 object detection on their screen content without the need for pre-recorded media or additional hardware.
  • 👨‍💻 Developers can now seamlessly integrate YOLOv5 into desktop applications that work with screen content, enhancing automation and monitoring solutions.

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 @zombob, 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 ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all YOLOv5 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

@zombob this looks good but we want to minimise changes to detect.py, as we’ll need to duplicate any code changes there to segment/predict.py and classify/predict.py.

Can you pass the —source screen args to LoadScreenshots and parse args there?

@zombob
Copy link
Contributor Author

zombob commented Sep 22, 2022

@zombob this looks good but we want to minimise changes to detect.py, as we’ll need to duplicate any code changes there to segment/predict.py and classify/predict.py.

Can you pass the —source screen args to LoadScreenshots and parse args there?

Fixed.
And changed the name "LoadScreenshot" to "LoadScreenshots".

@zombob zombob closed this Sep 22, 2022
@zombob zombob reopened this Sep 22, 2022
@zombob
Copy link
Contributor Author

zombob commented Sep 22, 2022

God!
New bug: if use "--view-img", every screenshot show a new opencv window

@zombob zombob closed this Sep 22, 2022
@zombob
Copy link
Contributor Author

zombob commented Sep 22, 2022

Fixed! Fixed! Fixed!
Take screenshots as streams:
"--view-img" to show one windows;
inference result save as "X.mp4" file. (X is screen number)
inference text result save as "X_XX.txt" file. (X is screen number, XX is frame sequence number)

@zombob zombob reopened this Sep 22, 2022
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
@glenn-jocher glenn-jocher changed the title add screenshot as source Add --source screen for screenshot inference Sep 22, 2022
@glenn-jocher glenn-jocher added enhancement New feature or request TODO High priority items labels Sep 22, 2022
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
@glenn-jocher glenn-jocher merged commit 30fa9b6 into ultralytics:master Sep 22, 2022
@glenn-jocher glenn-jocher removed the TODO High priority items label Sep 22, 2022
@glenn-jocher
Copy link
Member

@zombob great to hear that the issue is fixed! Thank you for the update, and we appreciate your efforts in improving YOLOv5. If you have any further questions or need assistance with anything else, feel free to ask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants