Learn Code By Gaming How To Bot with OpenCV - OpenCV Object Detection in Games #9
🎯 Загружено автоматически через бота:
🚫 Оригинал видео:
📺 Данное видео принадлежит каналу «Learn Code By Gaming» (@LearnCodeByGaming). Оно представлено в нашем сообществе исключительно в информационных, научных, образовательных или культурных целях. Наше сообщество не утверждает никаких прав на данное видео. Пожалуйста, поддержите автора, посетив его оригинальный канал.
✉️ Если у вас есть претензии к авторским правам на данное видео, пожалуйста, свяжитесь с нами по почте support@, и мы немедленно удалим его.
📃 Оригинальное описание:
Learn how to combine OpenCV object detection with PyAutoGUI and Threading to build a custom Python video game bot. Using the OpenCV image recognition techniques discussed earlier in this tutorial, we can now use that data to perform mouse clicks automatically. We’ll use Python threads so that our bot actions can happen independently of our object detection.
Full tutorial playlist:
Grab the code on GitHub:
PyAutoGUI:
PyDirectInput:
Automating mouse clicks
Basic threading
Advanced threading
Botting logic
Enum data structure
Stack data structure
Bot demo
Email me: ben@
Full written tutorial:
My gear:
Building a bot with OpenCV is a matter of combining the object detection techniques that we’ve discussed (in the last 8 parts of this tutorial series) with some GUI automation. Now that you know how to find an object using OpenCV, you just need to use something like PyAutoGUI or PyDirectInput to click on the objects you find. But there are a few architectural decisions that can make it kind of difficult to know where to get started. So I’ll walk you through one way to approach this that should be pretty flexible and act as a good foundation for building a more capable bot.
The most straightforward way to add automated mouse clicks to our bot script is to do it inline. By that I mean we can take a screenshot, process it to find the objects we want, and then perform any actions we want our bot to take. So we can do that sequentially, and just loop back around when our bot is done with its actions. So let me show you what that would look like, and then I’ll point out some of the limitations with that method.
[see the code samples on ]
In this code, once we have the detected objects in the form of a list of rectangles, we first convert those into click positions using the get_click_points() and get_screen_position() functions we wrote previously. Then it’s taking the very first screen position in that list, moves the mouse to that position using (), and then we use PyAutoGUI again to do the mouse click. Hopefully this has resulted in clicking on our target (a limestone deposit in Albion Online), and we pause our script for 5 seconds using sleep() to give our character time to do that mining.
So one of the problems this code has is it’s going to take at least 5 seconds between each update of our debug output. That isn’t great for seeing how well our object detection is working, compared to the continuous video stream we had before. But writing a bot this way will still work, and it keeps things simple if you don’t mind doing the object detection only when you need it.
If you want to get more advanced, you can fix this problem by using threading.
Threading, or multithreading, is the ability that all modern computers have to run multiple processes or threads in parallel at the same time. This is what allows you to have multiple programs running at once. Right now our bot script runs as just a single thread, but by using the Python threading library we can make it branch out and do multiple things at once (run in multiple threads).
In our case, what it’d be great to do, is to have our main script running in the main thread, and then branch off our bot actions into a separate thread. That way the bot can go off and do the things it needs to do without blocking the execution of our main thread where the object detection is happening.
In the main loop we call Thread() to create a new thread object in our program. We tell it what code to execute by giving it a function name as the target, and then passing in the parameters needed by the function as a tuple. We can then run that function in a separ
3 views
0
0
1 month ago 00:14:46 11
How I Learned The Hardest Tool in Blender
1 month ago 00:09:51 1
Urgent Remote Hiring: Don’t Miss Out! Great Pay/ Benefits
1 month ago 00:13:26 5
[Sean Foo] Brutal: US Chip War Goes Global, But China’s Light-Based Chips Threatens Total Wipeout
1 month ago 00:03:30 1
How to Buy Hostinger Hosting with 91% Exclusive Discount Coupon Code! 🌟
1 month ago 00:04:28 4
Firefox and Tor hit with 9.8 critical level exploit
1 month ago 01:17:48 1
🔴 RED ALERT: Military Now Authorized to KILL Americans on U.S. Soil? Ron Paul’s Dire Warning
1 month ago 00:09:19 1
Nuxt Authentication: SSR Authentication Patterns for (Дата оригинальной публикации: )
1 month ago 00:41:31 8
[Learn Code By Gaming] How To Bot with OpenCV - OpenCV Object Detection in Games #9
1 month ago 00:27:02 4
[Brackeys] How to make a Tower Defense Game (E12 USER INTERFACE) - Unity Tutorial
1 month ago 00:08:48 2
Лучшие бесплатные мобильные приложения 2016 для iOS и Android — ТОП 10!
1 month ago 00:27:13 2
[Daniel Laera] *First Person | Detailed VLOG* A Day In The Life Of A Software Engineer in Switzerland🇨🇭 | Episode 4
1 month ago 05:52:08 1
Learn Data Science Tutorial - Full Course for Beginners [ua-CiDNNj30]
1 month ago 00:03:37 1
Describe People’s appearance ESL English - Has got - listening practice
1 month ago 00:12:52 1
Camera Projection In Davinci Resolve 16 | 2D to 3D!
1 month ago 00:51:03 1
NGINX Tutorial for Beginners
1 month ago 00:11:01 1
Установка Microsoft SQL Server 2017 Express на Windows 10
1 month ago 00:05:20 1
After Effects Tutorial: Cinematic VFX with Generative Fill for Video
1 month ago 00:04:28 3
[Fireship] Firefox and Tor hit with 9.8 critical level exploit
1 month ago 01:33:52 1
Learn Web Development And ACTUALLY Get A Job | Ultimate Guide
1 month ago 00:21:33 1
Remote Jobs Up To $38 An Hour! Companies Hiring Right Now
1 month ago 00:03:47 1
3 Categories Of Offences In The Canadian Criminal Code
1 month ago 00:15:56 2
Mastering the Art of Bo Staff Spinning: Top Techniques
1 month ago 03:02:33 1
Natural Language Processing with spaCy & Python - Course for Beginners
1 month ago 00:15:53 1
Making My Own “Book Nook“! || DIY Bookshelf Insert