How to make advanced image recognition bots using python
Vložit
- čas přidán 10. 03. 2020
- This video will show you how to make image recognition bots as fast as possible using Python. I will cover the basics of Pyautogui, Python, win32api and by the end, you should be able to make a bot for pretty much any game.
Here are the commands to run and code to paste: github.com/KianBrose/Image-Re...
All code can be found here: github.com/KianBrose/Image-Re...
If this video helped you please consider subscribing and leaving a like, it helps a ton!
If you have any errors/suggestions please let me know!
Discord server: / discord - Jak na to + styl
IMPORTANT NOTE!!!!
Newer versions of pyautogui make the == None solution give an error. To solve that you can write it like this:
while 1:
try:
if pyautogui.locateOnScreen('image.png') is not None:
print("Yes")
time.sleep(0.5)
except pyautogui.ImageNotFoundException:
print("No")
time.sleep(0.5)
IMPORTANT NOTE!!!!
1. DO NOT USE PYCHARM OR VISUAL STUDIO WHEN RUNNING THE CODE.
These programs require additional setup which I did not include in the video. Please use the idle editor to RUN the code. Feel free to edit or write the code in any editor, but run it with idle.
2. ImportError: numpy.core.multiarray failed to import
This is due to the numpy 1.19.4 package which is required for opencv being broken. To fix it uninstall numpy with "pip uninstall numpy" and install the non-bugged version with "pip intall numpy==1.19.3"
3. Pillow package missing
For any of you that get "Pillow" package missing problems install it with "pip install Pillow" in the cmd
4. The script moves the mouse but doesn’t click:
This is due to the delay between the LEFT DOWN and LEFT UP in the click function being too low. This means that the click is happening too fast and that either your computer is too slow to register it or the computer or whatever program you are using detects it as a “fake click”. To fix it just add more delay, I recommend a time.sleep(0.5)
5. I am on Mac/Linux and can't install pywin32
You can use pyautogui.click(x,y) instead, a few comments mentioned that you can edit the click duration by setting pyautogui.PAUSE(0.1) to make the click last for 0.1 seconds for example
6. I can't rename a file to .py (Windows)
Open file explorer, click on the "view" tab and check the "View file name extensions" checkbox and then try again
7. I get permission errors / Don't see the "Edit with idle" button
Open windows search, search for IDLE, right click it, run as admin, press File-> Open (Or file->New if you want to create a new file) and go from there
8. Pip is not recognized as an internal or external command
You forgot to check the "add to path" checkbox when installing python
Uninstall python and reinstall it while making sure to check the checkbox or follow this stackoverflow post that explains how to add pip to path manually
9. while I: invalid syntax error
It's not the letter i, it's the number 1
When I start the program, the mouse doesn't move, but the debug says, that it has moved. When I move my cursor, the cursor jumps to the place, where it is supposed to be. So I have to constantly wiggle my mouse back and forward for it to go where it is supposed to. What should I do?
I'm not sure what you mean by "doesn't move", does it move but not click or literally not do anything? Do you have python 3.7 64 bit? Are you running it FROM IDLE?
@@KianBrose Does not move or click or do anything until I touch my mouse. Then it jumps to the correct spot.
@@sumbo8452 Can you show the code through pastebin?
@@sumbo8452 Ah i see, the issue in your script is that in the while loop you have a TON of unnecessary delays. remove all of the time.sleep's from the while loop and try again
Bruh, I don't even need to put this on 1.5× speed, it's already on it, 10/10 tutorial
You might even have to slow it down lmao
@@KianBrose already have lmao
@The Clutcher the alt tab mastermind
@@SquidBeats I don't think this has anything to do anything here
@@turtle8558 its a bot on a bot making tutorial. THE AI IS GETTING SMARTER!
PLEASE make more videos like this. Everything is easily understandable and the topic here is exactly what im interested in.
working on one
@@KianBrose Nice work do you have a discord server ?
@@ygate4546 see the description.
@@KianBrose you're freaking insane, even if it's "basic" things and even if i already knew how to do that, i learnt a lot of thing. you explain fucking well, do more videos bro good job !!
Yeah, I understood everything and I don't use python. It's perfectly at the intermediate level for people who know programming but don't know this specific thing (making a bot)
Tutorial "How to make advanced image recognition bots using python
" :
- Step 1 : Import a library that will do the advanced image recognition for you.
- Step 2 : press run
Pretty much
What library can I download?
"Tutorial"
😂
@@thehoodshooter1985 Please tell me if have found the the answer
Im fairly new to python and this was perfect. The pacing was great, and you made sure to cover any question I might have had, for example what exactly certain commands do. I loved it. Great teacher.
Great to hear!
@@KianBrosesup
I’m here before this channel blows up
Same
Same
#metoo
ikr.
same
that's a pretty good looking stickman, not gonna lie.
Ty! It took a whole 20 seconds and a mouse
Wow he still replying
@@ayushbansal7061 yes
@@KianBrose Can u make stickman for me? Please
@@leksmar xd
This is the alpha chad of tutorials. Good speed, good info and good explanations.
Keep up the hard work!
Ty!
CZcams recommendation made something great today, a new subscriber here. Love the simplicity, you teach me something new in less than an hour. Thumbs up!
Glad you got something out of it!
I'm a beginner in python and the pace was perfect. I learned a bunch of new cool functions and how to use them. If anything I can always pause and go back. I really enjoyed the straight to the point style, very concise and informative!
Keep up the good work
Thank you! will do
Hi! I'm a new learner too (like really new, I can only relate to some generic SQL queries and excel combinations). Any projects you suggest to show off or attempt on your own for fun?
Dude I thought this was one of those joke parody videos as you were going so fast,
I actually understood everything, and you taught a program in 4 minutes.
It's actually a great skill, much love dude👍🔥❤️
Thanks! Glad you stuck around and didnt click off xD
Goddamn that's one of the best beginner friendly tutorials I've seen in a while. Gj!
Glad you liked it!
This video is so underrated!!!
You're explaining advanced techiniques but also explaining what a FOR loop is
I tried making it comprehensively understandable to even first-time programmers
This tutorial is great. You didn't say something like "ignore this for now, I'll explain that later", at the same time you managed to explain everything pretty, and at the same time you kept your tutorial as short as you could, unlike lots of tutorial makers do. Subscribed at first sight! :)
Thank you! Glad you enjoyed it
@@KianBrose And the fact that you try to reply to everyone's comment makes you even cooler tbh
@@imaginaoCZcamssoquecomarrobas thanks
@Potato Tornado libraries...
@Potato Tornado They are just libraries tho
Thanks, this is exactly what i was looking for! These beginner oriented videos are very useful to someone like me
principiante
this is what i wanted! 15 min tutorial , which would usually last 2 hours. You told me what to keep in mind when making a bot, you showed some scripts and im ready to start and learn further on the way
As tutorials should be made, straight to the point
wow man, straight to the point and very educational for beginners like me. This is my first time I'm here, u are underrated!!
Ty!
This tutorial is very fast paced, short and concise yet covers all the information you need even as a beginner.
Perfect.
Thank you
a simple, straightforward, and relatively beginner-friendly guide for something that many people would consider out of their depth. good stuff man, keep up the great vids
r e l a t i v e l y begginer friendly
Glad you enjoyed it! Ty for watching
Thanks. Good work. The pace is just fine, all straight to the point :) Hope you are going to make more videos like this one.
Trying xD
The pacing was perfect, I learned a lot in those 15 minutes. Keep up the good content:)
Thanks, will do!
GREAT Pace! The whole video covers a lot, very quickly - so it's not too long.
It also has plenty of detail, so I can come back later and replay / pause to get any fine points I missed on the first run.
Ty! Glad you liked the fast pace ^^
Everyone's a gangsta until Kian writes a bot on IDLE
Then the economy of games starts crashing xd
@@KianBrose i press f5 but nothing happens in aimbooster
@@mornelouw1266 you probably need to press f5 in IDLE and switch to the aim booster window
@@Azurade aimbooster ?
lol
I started to learn python mostly by myself, and despite the video being a little fast for me it was really understandable and helpful.
Practice makes perfect!
Subscribed simply due to the fast pace and that it was intentional. Many are so slow I lose interest or 2x speed due to my adhd.
Very informative and to the point. Lots of great useful and flexible for other projects. Give us all he needed info while not being too "hand holdy" and "hello world" intro style. Throw me in the deep end!
have adhd as well xD Making things fast and cutting out irrelevant parts is something I would enjoy as a viewer, so that's why I made it like this haha
I wanted to learn python for a long time, and I just learned the basics in 15 minutes! Thank you very much sir
Np, glad you enjoyed it
Love the fast pace as everything that needs to be read can be found in the description, and the way you explain makes it super easy to follow. I'm subbed and gonna binge your videos.
Thanks for the info! :)
Thank you! Glad you enjoyed the fast pace
@@KianBrose
Framförallt "inhalera" 😂
Hahaha
The pace in the video is perfect for everyone im a beginner in python and this seems clear and helps so much even with other projects i come back to this video thank you!
Glad it helped!
I just got back into coding cause I didn’t feel like I was progressing the way I wanted, but I realised that I should go do some projects and pick up new skills, this video helped out a lot, it was clear snd concise thank you a lot, you got a new sub
Thanks!
@@KianBrose no problem keep up the good work
Man, this is bomb. Great quality and very easy to follow along and understand. Thank you Kian!
No problem! Glad you found it easy to follow
Me: Makes a Calculator in pyton
Friend that i dont have: Ohh so your a hacker.
Lol
LMAO
so true
Rolf
I work with console for coding purposes and my family thinks I am doing illegal hacking. So reltable
Probably 1 of the best tutorials I have found on CZcams for Programing.
ikr
Not only good programming, fun, and a good sense of humor.
I like your editing, and how the text is put, like jokes like inhale.
Thank you!
i love this video its fast paced and no bs... im so tired of people trying to add in stuff that doesnt nee to be there... thanks.
same, glad you enjoyed it!
amazing tutorial. I love how you skip straight to the point and explain things on the fly. any other youtuber would've turned this 15 min video into a 10 episode series. subscribed.
Thank you! Yeah I hate it when educational content makes it pointlessly long
This is one of the best programming tutorials I've ever seen.
Ty!
One of the best tutorials i've ever seen, great job Kian!
Thanks!
this is the exact thing I was looking for, beginner oriented videos on python and AI, would love if you made more of these videos, earned like and subscription, many thanks
Thanks for the sub! Am currently working on a highly requested video where I explain and show the process of how I automate a game
looking forward to see it!
Such a refreshing breath of life for the Tech tutorial platform. At no fault to those within this field, many of us are far too a timid person to come out and make content such as yourself. Love the editing, love the personality, and very easy to follow. Though simple, its all the info i needed to get working on my own source for my own applications. Loved the vid. ;) got my sub friend. Keep it up!
tyvm! Working on the second one, I feel a bit bad for having such a broad upload gap but my school just decided to put all assignments at the end of the year... Unfortunate but oh well, I'll work on the second one soon
@@KianBrose when i try and install the pip files it says...
'pip' is not recognized as an internal or external command,
operable program or batch file.
Kuruluş Osman Music then you didn’t check the add to path checkbox when installing python
@@KianBrose ok thanks
Thanks man, you solved 2 of my problems with one video that was super easy to follow. You're really awesome.
Glad I could help!
loved the pace of this! quick and thorough!
Ty! Glad you liked da speed
Great pace! Would enjoy more python botting vids.
I love this fast paced videos, perfect for quick understanding and learning. New Sub!
Thank you! Glad you enjoyed it!
Best python tutorial I've ever seen, quick and explains everything unlike other torturials that just tells you to past this code and run it, also this can be used in many other thing
Ikr!
This video really saved me because i am doing a minecraft mining bot and the lava detection was way to slow and this method of checking the rgb values of the pixels really helped me
Glad to hear that!
Amazing, do make more videos like this! Especially something beginner oriented.
That’s the perfect speed! Make more videos! Loved it thoroughly!
Working on one rn xD
the video was compact, informative and in general so well made, thank you!
Glad it was helpful!
I have learned python basics in the last few months, what I see here is absolutely INSANE !!!, opens ENDLESS possibilities for me!! Thanks Kian & I'm subscribed! [:D
Glad it helped! Gl on the adventure!
Great video,right down to buisness just how it should be.Hope your channel grows.Would love to see more of your videos.
Thanks!
Hello Kian, thanks for making these videos. Its really cool to watch and to follow.
Request: in case you are interested, please also make videos on some productivity boosting automations that you think could be useful for pc/mac.
hmm other than shortcuts bound to specific keys I don't really see a lot of uses. This could be very useful for repetitive workflows though
This guy literally explained what FOR loop is in image recognition video, it would really help beginners to understand what's happening in the video, Keep up the good work!!
Thanks! Yeah i tried to make it understandable for everyone
your way of explaining is magnificent,
we are waiting for other videos and other subjects (API, MACHINE LEARNING...).
again, Best tutorial,easily understandable. Thanks, Kian!
Glad you liked it!
I just finished a IT exam and youtube recommends me this video, and even if I don't like python, I watch it all.
So good job.
Glad you liked it!
You can't not like python
@@rami-succar7356 I'm from a C++ C#, and specifically I hate the fact that there are no parenthesis and that there are libraries from everything and not a standard way for the basic things. But don't worry, I have friends that are trying to convince me to use it.
this is perfect for people who are already fairly proficient in python/programming and wanna figure out how to make a bot but its also detailed enough for a noob to just copy what you did and modify it a little. MORE LIKE THIS!!!!!
Glad you liked it!
This is the best tutorial i have seen. AMAZING. Please keep up the amazing work! And i love your sense of humor. LOL!!! Subscribed!
Thanks for the sub!
This is one of the best channels I have ever found. Your tutorials are so helpful.
Happy to hear that!
This is the beat tutorial I've ever seen, good job!
Thank you!
Great vid dude!! This is exactly what I was looking for! Thanks!!
Happy you found what you were looking for! Now go automate those games xD
I already begon! ^^ I don't have any problems for now!
It was so fast for me 10 days ago when I first watched this tutorial: I had no idea about python and had to pause the video so many times, but not anymore now! You helped me notice that I am evolving haha. Great vids btw. 👌
Ty!
Fast pace is good! I can always pause at look at it if I am having trouble catching anything, but I can't stand slow videos, it's such a waste of time and much harder to adjust to my liking. This is concise and straight to the point which should be the aim of all programming videos. 0 useless information. No intro, no chatting, just straight-up information through both audio and visual (fantastic editing as well!) Just perfect. Please keep it like this :)
Will do!
I came over from code bullet to understand how he works when training AI. I wanted to understand how pyautogui works to use it on my own. Now I know it. Thanks for this amazing pretty solid video. The speed of you telling to content was chosen very well.
Thank you! I'm glad you enjoyed the pace
Hi sir is it possible to make automation for online game
Sir please reply
@@random-shorty6092 yes it is i would personally say
This was a really good tutorial! It was really easy to follow
Happy to hear that!
Man, this is one of the best programing videos i've seen, no jokes, you are great!
Thanks!
Excellent, bro! Keep creating this kind of tutorials.
Thanks, will do!
der hat mir zu wenig streams
Kian, if you use Shift + Right Click on a file, you will see 'Copy as Path'. This will save you some steps getting file paths for assets. This way you don't have to copy the asset's parent directory path, and then add the name of said asset to the end. Plus, it copies with quotation marks by default.
true
This is quality content right here. Subbed.
Thanks for the sub!
This fast pase tutorial was freaking great thank you so much
No problem! Glad you liked it!
Hey dude your pace is perfect thank you.
Glad you liked it ^^
one of the best coding tutorials i have ever watched
Thank you! Glad you enjoyed it
Great video! Pretty easy to follow and understand and covered some topics I wasn't familiar with in Python. The only suggestion I'd give is making some of the variables less "hard-coded". I think the region you're displaying should be set as a global variable to make changing the code significantly easier in the future. Otherwise, great video!
True, but for this kind of script where the region only has to be declared once I don't think it's necessary to declare it as a global variable since it may confuse some people. Glad you enjoyed it!
This is an EXTREAMALLY BASIC approach... and that is why i love it!
glad to hear that!
Thanks! Is so helpful :) subbing now
I solved the double click issue and removed any pauses by checking if last click x was within 10 pixels of the previous clicks x value
Glad you found a use for it!
Extremely Nice tutorial, straight to the point and easy,
Why do you so less subscribers????
God bless you!
PS:I was learning OCR with vbs since many days to automate a game, but this really makes it very easy!!
Glad you found it useful!
Good job. Keep em coming! Thank you and cheers :D
Np! Glad you found it good
Bruh you are a God! teach me more, explanation is concise and precise. Please make more videos like these with varying complexity related to pregresion.
To be honest i don't know a lot of things myself, but the little i do know i try to reach through here
Actually I am using this concept in other stuff, but it really helped me. Thanks for this awesome video.
Glad it was helpful!
4:03
Kian Brose: allow flash if you want
me in 2021: now that's a name i've not heard in a long time
That part didn't age well xDDDDDDD
Thanks, this is exactly what i was looking for!
Glad it helped
I like the speed. This way I was more focused to watch. Ty please more of this
Fast is how it should be xD
Im using visual studio and it works fine, awesome!! used the vid as reference and made my one pretty fun :)
The video is really well done and informative, I might have to steal this video style! 🤖
Dewit
@@KianBrose Wow did not expect you to respond! :D I'll try!
Bro, how come you have only 1.8 thousand subs? Insane, I thought you had a 1.8 million when i checked, the content is that good.
Thank you! Hopefully I made it to 10k by the end of next year
@@KianBrose nah mate, you've blown up ig. You'll have 10k or probably even more by the end of this year. Cheers to that! 🥂
Jbtw a new sub here!
@@KianBrose Print("You predicted that! I know! You're on a nice 8k and it's kinds like the end of the year! Keep up the good work. Dw, you'll get to 12K + in no time. :)
Regards,
~another subscriber")
Thanks a lot dude, just what I was looking for!!
Np!
This video is good, the pace is poggers and the explanation is good.
Thanks!
So this channel is at 3.06k sub count and I can predict the future my friend ✌️ Nice decision man to put videos... Keep going 😁 as I'm getting knowledge free of cost😁😁
Enjoy the free tutorials!
Why didn't CZcams recommend me this before i don't have time rn but will surely try this new stuff!
Also this fast paced learning is what people like!!
Well it seems it's working just fine seeing how the channel is growing xD
For your r,g,b for loops, it saved me a lot of time to do if b>0 and b < 25 and g > 25 and g
Glad it worked out!
My first ever comment on youtube!! You are amazing! I have been tryn to learn all these things for like 2 weeks or so and was unable to collect sufficient knowledge to start working on pyautogui etc. You did an incredible job. surely going to subscribe for more
Thanks!
Wow was really expecting for u to have loads of subs but dont. honestly u deserve sum more
Tuttifrutti10 thanks! Hopefully someday I’ll make it to 100
Little did I know
@@KianBrose come back to this comment in a year
@@KianBrose u look more like a sub with 1M
man please make more videos, best channel, you are make every thing easy and simple, i can't wait foe more videos.
i got a few xD
@@KianBrose
Please (: do some more I'm waiting...
Also That awosome how you reads the comments after long time.. XD
I do the same code as you but I got a problem which is click in the same goal a lot of times, So I think that because the speed of clicking but it dose not change, then I thought that the screenshot is very slow comparing to the goals.
I Import Library called mss
Which allow to take a screnshots very fast than pyautogui..
And the problem is fixed (:
So if you use it in next videos it will be fantastic.
The code that I use like this:
sct = mss.mss()
scr = {"top" = t, "left" =l, "width" =w, "height"=h}
img = sct.grab(scr)
for......
r, g, b = img.pixel(x, y)
It is works pretty well
I got what I was looking for in less than 4 minutes.
Thanks!
Youre welcome!
Underrated you will get 1M soon for this type of amazing content
Hopefully someday
@@KianBrose I belive
Omg he explaned it in such an easy language. 🤩
English! Yes!
The most productive 15 mins of my life! Thank you for this amazing tutorial!
Glad it was helpful!
This is exactly what I was lookin for ....
Thanks man :)
Np
This tutorial is better than 90% of the programming tutorials online (fast and accurate)
Ty!
@@KianBrose I currently try to create a bot. Let say I start a timer, and I want to stop the timer when autogui catch a "9" in second.
So, when I stop timer, it shows 9:40 millisecond, which means 400 Ms delay.
I wonder if there are any better modules that image recognizes target image on screen quicker 🤔
Big thanks!!
Will you make more tutorials ? This stuff is fun to watch plus we can learn so much. As a foreign who doesnt know english that good its amazing i can understand everything.
Yep, I will
I'm so blessed I discovered this channel. Man you are a f***** genius ! Keep doing like this.
I would not be surprised you work for SpaceX or NASA
It's just a simple python library I showed though...
I LOVED the fast pace. Great video
Glad you enjoyed it!