Great video, love to see more like this. Automating games like this is an amazing way to introduce people to OpenCV, it's simple to explain but teaches you important skills applicable to a much wider range of tasks. I'm glad I randomly stumbled upon your channel, your videos don't get nearly as many views as it deserves for such high quality educational content.
@ClarityCoders3 жыл бұрын
Glad you enjoyed it! I'll have more coming soon!
@yichong7773 жыл бұрын
I agree, I had my first coding experience from minecraft because I wanted to automate a turtle in the modded game xD
@ClarityCoders3 жыл бұрын
@@yichong777 Thanks for the comment it means a lot. I was getting beat up a bit today haha...
@bobchelios99613 жыл бұрын
i bascily became a programmer by starting to atuomate games. learned many skills from basic programming to ocr to stock market theroies to reinforcement learning while doing that.
@johndorian40783 жыл бұрын
@@bobchelios9961 So did i....... which is why it's kind of a shame some games are so quick to ban.
@ArcaneEther3 жыл бұрын
To circumvent the missed image detection from a day/night cycle, you can add a desaturation to both your sample and comparison images to grayscale them before comparison. This usually works for pixel-based art styles, as day/night is usually just an added color filter over the original image. The exception being those games that use specular or bloom lighting effects, which can distort the end-result grayscale in the image. The trade off, however, is that the added step of desaturating the sample image on each frame will slow down the script a bit. EDIT: This method also wouldn't work in games that reuse sprites with different color palettes, for obvious reasons.
@ClarityCoders3 жыл бұрын
Yes sir! Very good points this is something I've used in a few projects and probably should have talked about! Great comment.
@mrhitsjr47753 жыл бұрын
hey could you help make a open cv for shooting the ball in nba 2k
@andrjsjan4231 Жыл бұрын
I didn’t get it why do they use different color palettes for different reasons?
@ChrisCox-wv7oo9 ай бұрын
Differentiate objects by color is a cost effective way of expanding the object types in game. Red goblins are fire goblins. Blue goblins are ice goblins. If you want to use flame thrower on red goblins, and water gun on blue goblins, you need to be able to determine type you're identifying. That's the issue discussed above.
@Primu Жыл бұрын
15:15 A more efficient solution here would be to just check for rectangles with intersecting regions. Not sure about python but in c# this is very simple with the Rect.IntersectsWith method (you can also just do it manually, the math is easy). Then you can combine them by inflating one rect with the difference from the other. Also for more reliable matching, there are various imaging algorithms you can use, for my OCR projects I do: grayscale > scaling > binarization > inversion > denoise > bordering, this helps a lot for matching foreground objects over varying backgrounds. You can also start with colour averaging which can make scanning for objects significantly faster at higher resolutions because you can scan chunks of the image and skip processing any that aren't similar. I've used these methods for overlaying real-time translation of text in non-english games.
@mdellertson3 жыл бұрын
Amazing work! Thank you so much for sharing this! I would love to see a video on how to implement convolutional neural networks to do object recognition.
@ClarityCoders3 жыл бұрын
It's on my list for sure!
@AlgorithmAlloy3 жыл бұрын
You could have also done the grouping by comparing the distances of all rectangle centroids which would essentially create a node graph with every center connected to everyother center and then combining all nodes whose distance is below some threshold distance. Your solution works, I just think it’s good practice to use more general algorithms.
@ClarityCoders3 жыл бұрын
I would agree very good points. Thanks for watching and commenting.
@Beatsbasteln3 жыл бұрын
3:34 "now my hope is that we detect multiple instances of weed" yes pls!
@NoshNosher3 жыл бұрын
except he clearly says wheat
@Beatsbasteln3 жыл бұрын
@@NoshNosher are you sure about that bro?
@ells1013 жыл бұрын
@@NoshNosher Charles Shwab ova here
@emifro3 жыл бұрын
@@Beatsbasteln I am 100% sure he said wheat.
@Beatsbasteln3 жыл бұрын
@@emifro but how are you going to smoke wheat?
@pfever3 жыл бұрын
Your videos are awesome man! I really love them :D
@ClarityCoders3 жыл бұрын
Mean a lot thanks. I really appreciate the view and comment have a good one.
@DarkNemesis043 жыл бұрын
This is a really well paced and detailed guide! Great work :)
@ClarityCoders3 жыл бұрын
Thanks I work really hard on trying to figure out the best pace to keep people engaged and still not skip topics. I will continue to try and improve. Thanks for commenting and watching.
@maxfrischdev3 жыл бұрын
Oh, come on.. I just decided "Ah crap, just get started..(!) Ima start with the basic webstack and see from there. And then I stumbled over this channel and THIS video.. Great video @ClarityCoders!
@djbroake98103 жыл бұрын
Thank for the examples and how it all works, liked and subbed.
@stevesteverson33453 жыл бұрын
haha this is awesome, i've thought about doing it before and after this i might have to. One of the most relatable/interesting coding videos lmao.
@ClarityCoders3 жыл бұрын
glad you liked it! I hope you do please share it if you do.
@stevesteverson33453 жыл бұрын
@@ClarityCoders I already did :) although apparently the only way to grow small channels these days is to leave comments on a bunch of related videos so people click on your profile.
@ClarityCoders3 жыл бұрын
@@stevesteverson3345 Trying to grow your channel?
@stevesteverson33453 жыл бұрын
@@ClarityCoders hahah yeah come watch any of my 0 videos
@leonhardguss81503 жыл бұрын
Thank you man, this is awesome !!
@ClarityCoders3 жыл бұрын
Glad you liked it thanks for watching!
@mohammedyasser31894 ай бұрын
man!!!! your are amazing we need more of this content with this type of teaching methods
@joshuaolsen88443 жыл бұрын
I love to see you doing these videos! I’d like to see one that is based on real pictures, like “is the car pointed left or right” etc and incorporate some training and AI
@ClarityCoders3 жыл бұрын
Cool idea! I'll put it on my list.
@cosmicdive Жыл бұрын
Great tutorial, really enjoy and appreciate you explain what each line does in detail. Subscribed and liked!
@BusinessWolf13 жыл бұрын
Here's an idea to get around the different shades thing: transform all target images to black and white, and same with the recording output going into the program.
@gnack4203 жыл бұрын
Different colours will end up as different shades of grey though. The correct approach is what the library already does, which is normalisation.
@BusinessWolf13 жыл бұрын
@@gnack420 Shades imply there's color. What you wanted to say was value (lightdark). Sorry I got into definitions. But yeah, you're right. I wrote that comment before finishing the video, I didn't know you were gonna use an algorithm to find likely matches, I thought that whould require some deep learning or something much more advanced. Shows how much I know about programming. Oh, and btw, thanks for the video, it was really fun!
@prevensie3 жыл бұрын
Teaching archivement unlocked! congrats man! you are helping people from brazil!
@ClarityCoders3 жыл бұрын
I am from a tiny town in the US never thought people would watch me in Brazil. Thanks for watching and commenting.
@TheBuzz3r3 жыл бұрын
@@ClarityCoders 🇧🇷
@fenfire3824 Жыл бұрын
Ah thank you so much, i was looking for a tutorial like this for a very long time :) I did something similiar in auto it just for fun, but I always wanted do something like that in a "real" programming language with more powerful libraries. Thank you so much =) I only need to learn how to use it in 3d games /video capturing. But it is just fine to learn right from the start :)
@CharlesWeill3 жыл бұрын
I'm loving your content! As a fellow ML engineer, and fan on mini online games, I love this!
@ClarityCoders3 жыл бұрын
Thanks! I really appreciate the feedback and views!
@wyatt59843 жыл бұрын
I love the tutorial; keep up the great work! Heads up, I am coming for your high score ;)
@ClarityCoders3 жыл бұрын
I hope you do! Thanks for watching I appreciate it!
@wyatt59843 жыл бұрын
Your score has been topped! No template matching was needed since the game uses the exact same pixels in the same locations but still great to know that functionality exists within OpenCV. keep on keepin on.
@ClarityCoders3 жыл бұрын
@@wyatt5984 Yeah I noticed that as well haha! Gives you some flexibility for more complex games though. Nice score!
@ClarityCoders3 жыл бұрын
@@wyatt5984 Our discord is you're into that sort of thing. discord.gg/cAWW5qq
@rastatugan3 жыл бұрын
Pretty clear and very interesting, coming from C and learning Python and opencv for industrial purpose, you helped me a lot , template matching can be used in so many way in my work. you have all my respect and i'll follow you with great joy. Thanks again for your videos.
@ClarityCoders3 жыл бұрын
This comment really means a lot to me. Thanks for watching and commenting I'll keep making videos.
@elonmed2 жыл бұрын
thanks man. I love your teaching style
@franzdizon86593 жыл бұрын
this is what I have been looking for... THANK YOUUUU
@ruangustavomoretti7662 жыл бұрын
Thanks man, you saved my graduation project!
@gunnerstone1203 жыл бұрын
Nice; Solid introductory video! I enjoyed watching. Wish there was a fast & efficient template matching method that worked with a high dimensional image space. I imagine the game you tested in the vid was only 800x600 or something lol. When working with large images I usually have to search a small section or it will take too long to compute.
@ClarityCoders3 жыл бұрын
For sure I almost always cut down the area where I'm taking the screen shots. Especially if it's a real time thing where time matters. Thanks for watching and commenting I really appreciate it.
@SuperMasterDesaster3 жыл бұрын
You could also try speeding it up by scaling the image down before performing the template matching.
@ClarityCoders3 жыл бұрын
@@SuperMasterDesaster Yeah I really like this idea as well.
@RogerCh888 Жыл бұрын
This is an awesome, very straightforward tutorial. Thank you!
@youcandoit45023 жыл бұрын
Hi brother is it possible for you to make a chess bot with opencv as u make for other games or for knife hit game if yes please make a video on it .It will be really helpful .
@ClarityCoders3 жыл бұрын
Sure let me see what I can do! Hit that bell so you don't miss it.
@youcandoit45023 жыл бұрын
ohh I already done that as I like your content so much and thanks it really means a lot.
@Ali-Britco3 жыл бұрын
@Grzegorz Łabędzki awesome work, very readable code, even though I have no interest in chess.
@billowen32853 жыл бұрын
@@ClarityCoders please don't, chess sucks with cheaters. And if you must, at least don't release the code
@chuifrankz20702 жыл бұрын
best tuto about template match i have ever seen!helpful!
@maciej12345678 Жыл бұрын
how to open view on screen windows like there 19:51 ?
@saidalizade12912 жыл бұрын
Ty very much, i could not find someone explain this as well as you did ngl saved me
@USBEN.3 жыл бұрын
Very fun to watch and learned a lot. Thankyou.
@ClarityCoders3 жыл бұрын
Thanks for watching/commenting it means a lot.
@KiwiRedstone3 жыл бұрын
How to take screenshot and use it as a variable instead of writing it to file and reading it from the file. The issue I have is that first, I'm afraid that my harddrive age won't last that long with this method and second, it is faster
@ClarityCoders3 жыл бұрын
Check out the code on the github for kick ya chop. I do exactly that! github.com/ClarityCoders/ComputerVision-OpenCV/blob/master/Lesson3-TemplateMatching/PlayGame.py
@aowmovies865711 ай бұрын
Hey bro, you can google mines game usually available in rummy apps. How to create mines game bot? To make all cells visible by seeing all hidden covered mines inside cells/grid or uncover then through any method or using OpenCv(image recognition) algorithm method to identify exact mines in the cells/grid? Can you make that tutorial?
@patrickmueller96583 жыл бұрын
Liked and subscribed - explained and shown structured and clearly! Thanks!
@Promptshot Жыл бұрын
why is my match when copying and pasting from the haystack img 70-86% match instead of 99??? what am i doing wrong?
@walney20083 жыл бұрын
please your codi, dimensions_left = { 'left': 164, 'top': 92, 'width': 150, 'height': 250 } dimensions_right = { 'left': 520, 'top': 600, 'width': 150, 'height': 250 } , what config positions the screen corret ? what exemple ?
@Aloofang3 жыл бұрын
Thank you for making this video, it really helps me a lot.
@ClarityCoders3 жыл бұрын
I hope so. Let me know if you have any questions.
@officialonbekende97852 жыл бұрын
imshow,imread,and al the rest of the stuff that comes after cv2. isnt working . it says __init__.py isnt found .i reinstalled is 5 times but still nothing
@Conqueror18073 жыл бұрын
Here after watching CS Dojo's video :)
@ClarityCoders3 жыл бұрын
Awesome thanks for stopping by!!
@walidyoucefkahla61203 жыл бұрын
bro can you write it as a scipte cause i tryed and it doesn't work like yours the rectongel doesnt showed on the the colored image
@ihatechocolate66215 ай бұрын
I love this video and the idea, I don't know anything about coding but if you would every take a look at the game called "Parking master multiplayer 2" (the game requires a lot of repetition plays in order to have money, I would love to see you make a video about that game of how you would set up for it to auto drive the car into the parking spot!!
@hafizhnugrahav01133 жыл бұрын
woah you jump from 2k subs to 7k in 5 days, congrats
@fg87fgd3 жыл бұрын
Couldn't be more clear. Many thanks...
@CrynogarTM4 ай бұрын
I use IDA Pro to Dominate in Multiplayer Games. In HTML Games I reverse the Server requests and just need a proper parser or memory pattern.
@contantino_mm3 жыл бұрын
blessed by youtube algo.. found your video and subscribed!
@ClarityCoders3 жыл бұрын
It's actually given me some love this past week. Thanks for watching and commenting.
@Elislavkat Жыл бұрын
amazing. thanks. so much easy class from you
@jean-marctrutna40982 жыл бұрын
Is it possible to move the mouse to the location of the identified object on the screen instead of a pre-set point?
@khoinguyen96693 жыл бұрын
how to you make it run in background? like i want to do other stuff and the bot still running the game in the background
@melonman12523 жыл бұрын
just keep it running then or get it hosted
@HelloWorld-vm9gz3 жыл бұрын
Can i work with multiple models of an NPC (different color clothes, but similar image) in 3d? Like multiple images, side, front, back?
@ClarityCoders3 жыл бұрын
Might needs something a little more flexible like a neural network.
@Raid773 жыл бұрын
Amazing tutorial although I do have some ideas to improve some of what was presented, Firstly the rectangles grouping section, I'm sure there's a better way than just duplicating the list, maybe manually comparing the x, y of rectangles and if they are similar to another rectangle we don't use it The other point would be about beating the highscore, i would test for a single pixel's color above the player on each side where the background is static and check if it's color changes (a branch is above) and move accordingly
@impzhu30883 жыл бұрын
Wow, this is so cool! Thanks for sharing!
@ClarityCoders3 жыл бұрын
Thanks for the comment more to come stay tuned.
@xpcraft22382 жыл бұрын
when i click shift enter it dosent run anything can you help me?
@RiddleRations10 ай бұрын
Awesome video! Learned a lot!
@CapnSlipp3 жыл бұрын
You can also find the wheat points without overlaps by running a local maxima filter on the grayscale image- accomplished in OpenCV with a dilate filter followed by a compare filter. You might not need it for this use-case, but you can also additionally filter out plateaus of local maximum value with an erode and a compare (if you want to know what to compare against what, for the sake of brevity here either google it or just try a few combinations; heck, you don’t need Jupyter to figure out the correct operations; you can prototype this kind of stuff with Photoshop/Gimp layers easily). I like image-processing solutions like this because 1. For an end-use you can more easily run the whole thing on a GPU where operations over a whole image are cheap and reducing that an array of numerical results is the expensive part, and 2. You can visually see and tune/debug the dilated image, the dilated-compared image, the dilated-compared-eroded image, and the dilated-compared-eroded-compared image.
@ClarityCoders3 жыл бұрын
Very good points and great feedback. Thanks for watching and commenting.
@UTJK.3 жыл бұрын
Could this tecnique work to detect parts of a document (for example a rectangle with a text) in order to read what's inside that section of the document? It would be a scanned document so it could arrive with horizontal lines not perfectly aligned due the subtle movements of the paper durinig the passage under the scanner.
@Hato19923 жыл бұрын
I think you can make it much easier. OpenCV can detect rectangles in image. Next, it can detect text (OCR) within those rectangles. If rectangles are not perfectly aligned you can fix perspective of those rects in openCV too.
@4ur3n3 жыл бұрын
great job man :D
@ClarityCoders3 жыл бұрын
Thanks I really appreciate it.
@farmminer40143 жыл бұрын
Thank you! Very great guide to OpenCV! But how to optimize it to get it to run 100 times faster? How to use multiple CPU cores and GPU with OpenCV?
@pianochannel1003 жыл бұрын
@TridentflayerThe other thing you can attempt to do is vectorize your code very heavily so that you can do all of your calculations in numpy operations. Speaking from miserable experience, that can be far harder than just biting the bullet and doing it in c++
@XIAOBAIZHANG-ym8pn9 ай бұрын
Very good video, can you combine your idea into the online game of chess, and use OPENCV to identify the FEN position code of chess on the web page?
@4ngeek3 жыл бұрын
I always compared images with mean square root or structural similarity. Template matching seem to be more intuitive
@ClarityCoders3 жыл бұрын
Probably similar in speed? Thanks for watching / commenting.
@furkanakcakaya94433 жыл бұрын
expected to see dominating that online farming game
@ClarityCoders3 жыл бұрын
Sorrry! Maybe in the next one 😏
@Maric183 жыл бұрын
whats the music near the end?
@ClarityCoders3 жыл бұрын
Nico Staf - Fast and Run. Thanks for watching and commenting.
@Maric183 жыл бұрын
@@ClarityCoders hey if i can get you that engagement and get the name of the song ... double positive :D
@MrMatirafi Жыл бұрын
Hi i am beginner, i am preparing script for a similar game but the question is can i run script like this for multiple game windows lets say arranged in 3x3 matirx (just like tic tac toe) on desktop and would it work or do i need to implement something more?
@bartvrhijn2 жыл бұрын
Jupyter us perfect for a live demonstration 👌
@ClarityCoders2 жыл бұрын
I agree. I actually caught a lot of heat for using Jupyter haha...
@AobatrozFilms3 жыл бұрын
does it works with differences in the scale of the pattern and the image?
@ClarityCoders3 жыл бұрын
Not well. Depends though on how good you need it to be.
@KiraIsGod3 жыл бұрын
Pretty nice! Found this on my recommended. Subbed :)
@ClarityCoders3 жыл бұрын
Thanks for the sub / comment means a lot.
@anonymous-36953 жыл бұрын
how would this work in a 3d setting, like if objects are different sizes? can it be modified for that? it would seem to be expensive to check for many different sizes so im not sure that approach would work.
@ClarityCoders3 жыл бұрын
I would definitely lean into a CNN or some other neural network at that point. I don't think this would cut it.
@awanturnik9783 жыл бұрын
What to start with to understand it ?
@cancihancelebi34959 ай бұрын
Thank you very much my friend, first of all, I follow the wheat finding code exactly and it doesn't work. Can you send it as a working project rather than a tutorial?
@jeevan1016Ай бұрын
This is amazing. Can any GUI be automated using this? Can GUI testing be done using this technique?
@jackrdye3 жыл бұрын
2nd year cs student - these videos are awesome keep it up!!
@deplorablesecuritydevices3 жыл бұрын
Very useful, thank you for sharing!
@ClarityCoders3 жыл бұрын
Thanks for watching and commenting!
@Nougat_Noah3 жыл бұрын
Nice video but one question. Did you purposefully excactly double their highscore at the end or was that coincidence?
@ClarityCoders3 жыл бұрын
I didn't even know! Good to have eyes like yours on these videos. Thanks for watching Noah.
@joulesinwatt3 жыл бұрын
This is a huge inspiration.
@ClarityCoders3 жыл бұрын
thanks means a lot!
@carlospazuzu Жыл бұрын
Are you taking screenshots from the whole screen or just the browser content?
@ProBloggerWorld3 жыл бұрын
Dude, this is so genius. Thx!
@blubms85933 ай бұрын
Please give me an idea how to make bot Auto Combo?
@melonman12523 жыл бұрын
Great Video!
@ClarityCoders3 жыл бұрын
Thanks for watching protect that melon.
@iliqnew3 жыл бұрын
OOOR in order to get rid of the additional rectangles you could just use sets to make get rid of data repetition
@ClarityCoders3 жыл бұрын
Great Idea.
@prandrex1066 Жыл бұрын
Okay bro but there is a problem... You made the code using an image. What if I want to use it in a true game...?
@jakefreise76013 жыл бұрын
Instead of trying to group rectangles together, why not just find the local maximas of the correlation values?
@drdca82633 жыл бұрын
Oh, this might solve a problem I have. There’s some made up alphabet which looks like it was made with a fixed typeface, and I want to transcribe the text in the images into actual text in order to try to decipher it, and I think I know how to extract the characters, but I still need to find how to detect which character they are. I can’t use standard OCR because these are a made up alphabet in an Easter egg for a game.
@mateussantiago31312 жыл бұрын
ty cuz ive been having a hard ti getting started.
@ClarityCoders2 жыл бұрын
Anytime let me know if you have any questions!
@sunnev3 жыл бұрын
Hi, how to handle transparent image case?
@ClarityCoders3 жыл бұрын
I think you can compare transparent images BUT you have to make sure both your needle image and haystack image have 4 dimensions. 1 for the alpha channel.
@sunnev3 жыл бұрын
@@ClarityCoders thanks for your answer yea so i cant just simple crop image and compare. Because capture image do not have alpha information. Is there any method to do this ?
@gold-junge91 Жыл бұрын
Frage mich wie das ding drauf reagiert, bei mir zuhause meine Partnerin und ich schlafen 365 Tage bei Fenster ganz offen. 😅
@timetoplay292710 ай бұрын
Это работает для статики. Тут зерно имеет конкретные цвета и никак не меняется. Я пробовал этот метод и он не работает для динамических картинок. Например, на экране идет снег, и снежинки закрывают объект, задний фон объекта меняется.
@alonewolf76822 жыл бұрын
Thank You for this valuable video
@Atropin4ik2 жыл бұрын
@claritycoders Thanks fo the videos! May you guys comment on how do games (their developers) catch such bots? Asking for the ways around obviously)
@kasperschnack4143 жыл бұрын
In cell 10 you overlay the template match with the original image but you don't explain how - is this something that opencv can do for you?
@ClarityCoders3 жыл бұрын
It's done automatically when you call cv2.matchTemplate. Thanks for watching and commenting!
@kasperschnack4143 жыл бұрын
@@ClarityCoders thank you for making the video 🙏
@actionkey80423 жыл бұрын
ClarityCoders -very very awesome
@ClarityCoders3 жыл бұрын
Thanks I really appreciate the comment.
@actionkey80423 жыл бұрын
@@ClarityCoders DO MORE AWESOME THINGSS)))
@jaimetheone91502 жыл бұрын
This works perfectly on VSCode, but as soon as I turn it into an exe with pyinstaller it does nothing.
@hiperion_14163 жыл бұрын
getting game information from memory: 😴😴🤢🤬🤬 getting game information using opencv: 😎😎🤑🤑🥶🥶
@ClarityCoders3 жыл бұрын
Both can be crazy frustrating haha...
@hellod28312 жыл бұрын
Great video, very helpful
@lok_6 Жыл бұрын
Hi I nned a bot for league of kingdoms, can u help?
@eliebordron55993 жыл бұрын
this seems really really cool; I want to do that on forge of empires . I'll watch this at some point
@ClarityCoders3 жыл бұрын
Hope you do! Thanks for the comment.
@jeepjr3 жыл бұрын
Teacher, first congratulations for the channel. I need your help, I have a simple image with a range of 5 placements where the quantity is identified, how do I identify the biggest color type red and say where the X,Y is, and if you can help me, and only for create an alert.
@JohnWick-gy5vv3 жыл бұрын
wow i want this i am trying to detect object game refresh game plants every 15mins if plant is dry send telegram bot notification if not do nothing
@BebebnyaHuTao Жыл бұрын
This is awesome thanks for the tutorial! I just wonder how to implement the code with 5 multiple window (open at the same time)
@jeanregis90302 жыл бұрын
Great video thank you!
@giacomozanatta11783 жыл бұрын
how long does it take to the entire script to run? Is it possible to implement a similar thing in a dynamic robot? Thankyou
@ClarityCoders3 жыл бұрын
Yeah it's pretty if speed was an issue you would probably want to cut down on screen shot size and such.
@siswanto4045 Жыл бұрын
I'm imagining, how can I use template matching on GIS software.