OpenCV Object Detection in Games Python Tutorial #1

Поділитися
Вставка
  • Опубліковано 16 жов 2024

КОМЕНТАРІ • 327

  • @ilkayatil
    @ilkayatil 3 роки тому +120

    I just found out your video and even as a senior python and opencv developer I enjoyed watching all of it. Learning image processing through games is an excellent idea. Your presentation is clear and precise, I disagree with comments which states it is a bit boring. Your explanation level is just right for the beginners, not overexplaining things and exploding beginner's minds :D
    I wanted to take my time and display my support with a comment because you clearly dedicate your time and enthusiasm to create a helpful content for the community. You just earned a subscriber, keep up the good work my friend.
    p.s. About the not so perfect matching score, it is probably due to using jpeg format's lossy compression. After you saved those images as jpeg, they will have very small differences invisible to eye but clearly visible to code as in this example. You might prefer using PNG for lossless image saving or even BMP to get faster image write/read times (high fps).

    • @josh9761
      @josh9761 2 роки тому +1

      second this by far the best explanation i have came across, zoomed in code, well explained step by step

    • @E30Andy
      @E30Andy Рік тому +1

      I went through this tutorial but deviated by using png files instead. ultimately this makes the tutorial not work as written because the data was no longer in the expected format of CV_8U or CV_32F for the matchTemplate function. Just a warning for those that like to experiment lol. My understanding is that you can easily convert to the proper structure, but me, being a noob, did not find success with this. I saved my files to .jpg and moved on with the tutorial instead of getting hung up and everything worked.

  • @mangojango3745
    @mangojango3745 4 роки тому +63

    I was JUST looking up info on this. Who knew it would be from the guy I subbed to from a few days ago. Keep up the good work your putting out unique and great content

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +5

      Thanks means a lot!

    • @diegorivera_cr
      @diegorivera_cr 4 роки тому +1

      Thanks alot for this video! Do you think you can cover how to find an object and also detect when it is gone in a video game?

    • @jamiestwrt
      @jamiestwrt 3 роки тому

      Trueeee

    • @mangojango3745
      @mangojango3745 3 роки тому

      @Carroll Horsely stop scamming people

    • @Tradie1
      @Tradie1 3 роки тому

      Exact same here! What an underrated channel

  • @wingchangwow
    @wingchangwow 3 роки тому +24

    Honestly, the quality of your videos and tutorials is simply astounding. I'm constantly amazed that you don't have hundreds of thousands of subscribers....yet!

  • @Charvin
    @Charvin 4 роки тому +42

    This was something I was wondering about,
    Thank you. I don't think there are much interactive content like this out there. Glad to have found this channel.
    Thank you once again.

  • @setokibah4476
    @setokibah4476 4 роки тому +6

    Here I was wondering how i was going to pull of object detection, then my man presents the answer to me just like that! Always appreciate you, never fail to expedite my thought process!

  • @saint-jiub
    @saint-jiub 4 роки тому +13

    I'm on part #3 of your series so far but wanted to revisit this to say - you've been helping me get out of tutorial hell. Thank you so much Ben! You have an amazing teaching style; The documentation and comments along the way in both video & blog posts provides more clarity than other tutorials. Your channel is one of the best out there, please don't stop. Peace.

  • @oswaldogerardino
    @oswaldogerardino 8 місяців тому

    I'm from Latin America, and I understand your tutorials better than the ones in my language. You're great, thanks

  • @deusexpersona95
    @deusexpersona95 4 роки тому +7

    This channel is God sent. Keep going and you'll grow very fast

  • @pollos4157
    @pollos4157 4 роки тому +2

    Whoever disliked this needs their head checking, this was one of the best programming tutorials I have seen yet.

  • @MrFox-uf7kv
    @MrFox-uf7kv 2 роки тому +1

    why this guy don't have above 100k subs.. he explained it so good. +1

  • @Joshua-kr5fq
    @Joshua-kr5fq 4 роки тому +7

    Nice to see you taking it to the next level

  • @knightwithouthorse
    @knightwithouthorse 3 роки тому

    Thanks for the video, I'm from Brazil and here we don't have many good videos about OpenCv and Python
    , the simple and objective way you speak is perfect for me who doesn't is a native and thanks for not using so many slangs

  • @teslar735
    @teslar735 4 роки тому +1

    this channel is so much underrated.Very good content bro,keep it up

  • @EvolMe
    @EvolMe Рік тому

    hey i JUST found this channel today, MapleStory is my childhood favorite game so this has motivated me to learn to code and use maplestory as my game, my younger self is screaming right now lol love your content

  • @thedeveloper643
    @thedeveloper643 4 роки тому +4

    this guy should get more subscribers!
    thank you for the great contents

  • @alchercananea5975
    @alchercananea5975 4 роки тому +3

    Hi there Ben!
    I stumbled upon your channel because I wanna learn how to code.
    I watched this video to see if it interests me though I don't have any knowledge yet. But boy! You explain things so well that I get the idea of what you are doing.
    I am glad I've found your channel.
    +1 sub!

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +1

      Awesome, always happy to see new people giving code a try! Thanks for subscribing.

  • @eliotbicak8296
    @eliotbicak8296 Рік тому

    It took two years but I am very happy that I managed to find your channel! Thank you for the great tutorials and videos

  • @iamrockstar2101
    @iamrockstar2101 4 роки тому +5

    GOLD CONTENT
    thanks , i just needed something like this to complete my project
    you earned a new subscriber :D

  • @johannes-euquerofalaralema4374
    @johannes-euquerofalaralema4374 3 роки тому +1

    Hi there, this is the best channel about this content. I have watched your Videos about Python at least 20 times each! I am a beginner and was able to follow your explanation and even to costumize the code for my needs! Really amazing!

  • @warpcode
    @warpcode 4 роки тому +1

    I've just started getting into object detection in opencv along with tensorflow, yolov4 etc. Whilst I'm not using it for gaming, these tutorials have been great for real dynamic and practical applications and for that i want to say thank you :)

  • @БелальДадах
    @БелальДадах Рік тому

    I have started learning computer vision not long ago and basically you are the best. Thank you very much for your tutorials

  • @raakapena
    @raakapena 2 роки тому

    Your OpenCV videos inspired me so much, been learning constantly new things and doing some low profile botting too. Best channel I've stumbled upon in a long time :).

  • @hansenliu2000
    @hansenliu2000 3 роки тому +1

    God I love you and this series, the quality content we all need but do not deserve

  • @VersusBR
    @VersusBR 2 роки тому +1

    print("Hello from Brazil")
    Thx bro

  • @devpatel5597
    @devpatel5597 3 роки тому +1

    Underrated UA-camr. Great content!

  • @angelsdemons8520
    @angelsdemons8520 3 роки тому +1

    Open CV is great no denying but the library is just huge , it's full of functions to do all
    sorts of thing , this is a great advantage(keeps ur code short and neat) and disadvantage
    ( I really find it difficult to remember these lol)
    like think about it for a sec, there is function for like literally everything and parameters which makes no sense
    for newbies (like me myself), but nevertheless great video mate , really liked how u walked through
    the documentation (encouraging viewers to explore) and explained as much as possible while writing
    the code and made the video as short as it possibly could have been u certainly deserve more subs
    and recognition mate :)

  • @vromel4331
    @vromel4331 3 роки тому +8

    Bruh ty so much! You save so much time for as !

  • @darkferiousity
    @darkferiousity 3 роки тому

    Wow dude been watching a lot of videos on open cv and yours is far the best I have seen. Just the way you teach is awesome.

  • @GoeieWoofer
    @GoeieWoofer 2 роки тому

    Yooooo Ben i hope you are still Alive and coding! I honestly cant thank you enough for all your content! It has finally gotten me started with programming and coding, im studying to become a python developer and ive truly found my passion and calling in life now. The way you teach and explain things is amazing, wish i would have gotten help like this sooner in life! Much love for you

  • @LordXavier79
    @LordXavier79 4 роки тому

    Thx, People like you make the world a better place

  • @shdwrzr07
    @shdwrzr07 4 роки тому +1

    Hey man just want to let you know that I'm so happy right now as a gamer and python programmer :) You just earned a new subscriber!

  • @ovipaw
    @ovipaw 4 роки тому +1

    You are great bruh I'd literally crown u as king.

  • @brednbudder
    @brednbudder 3 роки тому +4

    I love your videos. they make it more fun to learn to code. thank you very much for taking the time to make these, especially into easily digestible chunks in a playlist. youre awesome!

  • @Joshua-kr5fq
    @Joshua-kr5fq 4 роки тому +4

    I just did the sentdex opencv tutorial so this is perfect

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +2

      Awesome hope it's helpful for you

    • @Joshua-kr5fq
      @Joshua-kr5fq 4 роки тому +3

      @@LearnCodeByGaming Stardew valley is about to get more interesting.

  • @onion9377
    @onion9377 4 роки тому +1

    Wicked video! thank you for the tutorial. After fumbling around with a few other guides, it was yours that really got me into it.

  • @WhyNotProgram
    @WhyNotProgram Рік тому

    Thank you, I love how you guide us through the documentation! This will help me start creating AI's to play games and automate tasks.

  • @shi-woonyi2605
    @shi-woonyi2605 4 роки тому +7

    Thanks for the tutorials, I like all of them, it's much more fun to learn coding/new libraries if the examples are interesting topics too in this case, games! keep up the good work, looking forward to future tutorials, OpenCV looks awesome.

  • @mcleber100
    @mcleber100 7 місяців тому

    Thank you for sharing your knowledge. Greetings from Brazil.

  • @redegs_
    @redegs_ 3 роки тому +1

    You did a great job at making this easy to understand, I followed it all the way through and it worked, Thank you

  • @dazealex
    @dazealex 10 місяців тому

    Brilliant channel. Enjoyed every bit of it. Love the short length. Subbed!

  • @SquallHart05
    @SquallHart05 2 роки тому

    You're an EXCELLENT teacher. Thank you!

  • @pcpardon
    @pcpardon Місяць тому

    Thank you for your efforts to make this video. What a clear explanation !!!

  • @Гусьэкономит
    @Гусьэкономит Рік тому

    It has been two years already, where is the continuation? Why did you abandon your channel? You explain better than all my teachers! You're the best! It has been 2 years already, perhaps you have improved object detection, bot performance, and their movement between points, or maybe there's something else interesting to see!

  • @fierce1340
    @fierce1340 3 роки тому

    Just stumbled upon your channel! Love the style and format! Can't wait to check out more videos!

  • @shadowhuntzgaming3055
    @shadowhuntzgaming3055 3 роки тому

    YOUR TUTORIALS ARE THE BEST IVE SEEN, THENK YOU SO MUUUCH!!!!!!!

  • @daltonrinck3617
    @daltonrinck3617 Рік тому

    Thank u very much for this video. It was Informative and engaging. Makes me want to learn more about OpenCV!

  • @ae171092
    @ae171092 3 роки тому

    great stuff. no idea why the views are not in millions. kudos

  • @lummi14
    @lummi14 9 місяців тому

    Great video. How did you manage that u get to see a complete documentation for every opencv function? Thx alot!

  • @FollyOx
    @FollyOx 2 роки тому

    Thanks dude, I want to make a very simple bot to automate a PIA element for a really old game and this is a good excuse to learn Python a bit more

  • @uzzifuzzi9884
    @uzzifuzzi9884 4 роки тому +2

    Can't wait to see where this goes

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому

      Same! I need to slow down on coding and catch up with making the videos.

  • @MrBru96
    @MrBru96 4 роки тому +1

    Thank you so much. Your explanations are so clear. I learn a lot from you. You are the best!

  • @theweebsamurai
    @theweebsamurai 4 місяці тому

    Thanks a lot man , This Video really helped me start using openCV

  • @mingyang9522
    @mingyang9522 4 місяці тому

    hey, thanks for the tutorial. will this work for 3d games with some modification or will 3d games be a totally different issue?

  • @topkek239
    @topkek239 4 роки тому +1

    This is my new favorite channel, thanks for good content ^_^

  • @PythonHarry
    @PythonHarry Рік тому

    love you so much, I love this course, you just got a Chinese Subscriber!!!

  • @OsmioGonzalez
    @OsmioGonzalez 4 роки тому

    (Español)
    Muy buen video, conciso pero detallado. Atiende a problemas pequeños de forma que permite aprender poco a poco y construir el código lentamente y de una forma muy natural. Mis felicitaciones sinceras, espero continúes con este trabajo de divulgación tan pulido. Solo me queda felicitarte de nuevo y seguir tu canal y aportes. Mucha suerte para el futuro.
    (English by google translate)
    Very good video, concise but detailed. It attends to small problems in a way that allows you to learn little by little and build the code slowly and in a very natural way. My sincere congratulations, I hope you continue with this polished disclosure work. I can only congratulate you again and follow your channel and contributions. Good luck for the future.

  • @jaski8143
    @jaski8143 4 роки тому +6

    absolutely amazing content !

  • @platine141
    @platine141 4 роки тому +9

    It would be great if you make a video about how to detect multiple objects and use the ai to recognise them while playing the game and it would be great to make it recognize the distances and range between objects

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +9

      Yes I'll be doing that in the coming videos. I've got at least 4 more planned for this series.

  • @tower1990
    @tower1990 3 роки тому

    Thanks Ben :). I really like your teaching style.
    Please do more if you’re available!

  • @renaud6904
    @renaud6904 2 роки тому

    thank you so much Ben ! I viewed your video, red your web site, and i have done my new project in few minutes !

  • @n1guild
    @n1guild 4 роки тому +5

    Great content as always!

  • @redmenace5536
    @redmenace5536 4 роки тому +4

    Thank you for your tutorials!Really appreciate it :)

  • @sangdilbiswal30
    @sangdilbiswal30 4 місяці тому

    you are such a great teacher

  • @amingholizad
    @amingholizad 3 роки тому +7

    I guess the "not perfect match" that you encountered is because of the jpg format which is a lossy compression format tha therefore some pixel colors are changed as the result of the compression. You could use PNG file for better results

  • @x_Unknown93
    @x_Unknown93 8 місяців тому +1

    hi i need some help! i got some errors trying to compile this here 7:51 and what else i need/program or anything that needs for this to work?? y got python with alot pip installed i got visual code and studio 2022, i got the img's in the same folder and everything but i got error everytime i cant get that black and white img

  • @JordhanRDZ
    @JordhanRDZ 4 роки тому +6

    YES !! This is going to be very interesting ! =D

  • @calmius24
    @calmius24 8 місяців тому

    Sup bro does Albion have any protection against emulated clicks? In other words do your have to use something like Arduino Leonardo to emulate a mouse or it works just as it is?

  • @sanyamchaurasia1542
    @sanyamchaurasia1542 3 роки тому

    LOVED IT!
    Please, please, please! I would love more tutorials like this!
    Can we also make basic games like tower defense, basic shooter, or something similar?

  • @dzdeparsio4676
    @dzdeparsio4676 4 роки тому

    thanks i will watch ur vids and learn this library with u
    keep up the good work

  • @AskAKill99
    @AskAKill99 10 місяців тому

    Amazing videos!thankyou so much sir!! Much praise for your work

  • @javagenbu7085
    @javagenbu7085 3 роки тому

    Thanks for the video my man, very useful and well explained.

  • @nolancao2878
    @nolancao2878 Рік тому

    thanks for these 9 masterpiece videos

  • @lordraphi
    @lordraphi 4 роки тому +1

    Nice video!
    Good for starting programming a mmorpg bot!

  • @sudhirbrahma
    @sudhirbrahma 3 роки тому

    excellent video. I am a newbie and hence my apologies in advance: I did not see you use the "deep learning of the cabbage image" to detect the cabbage in the pic. It was just what u did copy an image and look for it. The use the max probability value to detect or ignore. How would this improve with a deep learning of the cabbage done first?

  • @zarakikenpachi1238
    @zarakikenpachi1238 5 місяців тому

    Thank you for the video :)
    That s very interesting

  • @brasilAndrew
    @brasilAndrew 2 роки тому

    One question:
    It's possible extract data from finded object with opencv?
    I want find images in the screen and then convert to json, like:
    [{img: 1, title: 'test'}, {img: 2, title: "nice"}]
    Thanks for you videos, awesome!

  • @chrisj1947
    @chrisj1947 4 роки тому +1

    I no joke just started researching this and already trained a model with yolov3 to recognize iron ore on Runescape in real-time with openCV.

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому

      That's awesome Chris!

    • @Ehxx
      @Ehxx 4 роки тому

      Oh wow I'm trying to do the same exact thing haha.

    • @chrisj1947
      @chrisj1947 4 роки тому

      @@Ehxx If you need any tips feel free to shoot me a message

    • @Ehxx
      @Ehxx 4 роки тому

      @@chrisj1947 Mind adding me on discord? Executioner#4102

  • @ramborambo5677
    @ramborambo5677 4 роки тому +2

    Thank you for this. Keep em coming :)

  • @mavikrmz3472
    @mavikrmz3472 2 роки тому

    Do you have a video for object detection for outside environment. For example person or any object the same way training the object ? If not do you consider recording one?
    Thank you very much for your videos

  • @CallingTheReaper
    @CallingTheReaper 4 роки тому +2

    Love the videos dude! Looking forward to the next one! I was getting an error with this code, Had to convert both variables to greyscale?

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +1

      That's interesting. Maybe something to do with the format of the image files you used? Glad you like the videos!

    • @MultsElMesco
      @MultsElMesco 2 роки тому +1

      I had the same error. I was using PNGs but it worked well when I switched to JPGs

  • @Siuulolñ
    @Siuulolñ 2 роки тому

    Thank you so much for these videos, this is gold

  • @SolusAU
    @SolusAU 3 роки тому

    Your videos are super clear. Thankyou :)

  • @bimamrth
    @bimamrth 4 роки тому +1

    Nice this verry useful for me 👍

  • @Ehxx
    @Ehxx 4 роки тому +1

    Going to do any tensorflow tutorials? Seems necessary for any game im playing currently, cv doesn't like to match at different angles

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +2

      Definitely going to be doing TensorFlow at some point. Once I get through the more basic topics I want to do all kinds of machine learning stuff. Thanks for watching!

  • @kaioshin9143
    @kaioshin9143 3 роки тому

    Thanks for the video, I now learned what I needed. Cheers!

  • @zeratonlaveur4211
    @zeratonlaveur4211 2 роки тому

    Thank you very much, i'm a french student and your work is outstanding

  • @kevinflynn4867
    @kevinflynn4867 Рік тому

    Thank you Ben , very interesting content !

  • @auniquehandle
    @auniquehandle Рік тому +1

    bro what vscode theme u using it's clean af

  • @spadedaman4958
    @spadedaman4958 3 роки тому

    good video and a writeup! You are doing a great job!

  • @Lucasbc
    @Lucasbc Рік тому

    Amazing explanation!

  • @Charvin
    @Charvin 4 роки тому +6

    After going through the video, I have this doubt as to why is it only detecting one item, when the other ones on the original image is almost as similar to the cut out cabbage. Can this method detect multiple items which is the same and mark them as such? Instead of just pin pointing at only one?

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому +2

      Yes, good catch. The very next video is going to be how to detect multiple items. It's only getting one item here because we're using minMaxLoc(), and you need to approach the result differently to pull out multiple matches.

    • @Charvin
      @Charvin 4 роки тому +2

      Aha, like widening the scope a bit and allowing in more options to come through! Great. Thank you again. ^^

    • @nickjklol
      @nickjklol 4 роки тому +1

      It is using the needle screenshot as a reference and then drawing a rectangle around the object with the best match. While the other cabbages look almost exactly the same, that specific one is the best match.

  • @situwang1831
    @situwang1831 3 роки тому

    Thank you for your videos, you are very good, I have received a lot of inspiration

  • @lamvandinh789
    @lamvandinh789 2 роки тому

    Thank you for the great tutorial!

  • @RaySharif
    @RaySharif 2 роки тому +1

    I got the whole Code just like u but i get this error.
    Please help me!
    error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'rectangle'
    > Overload resolution failed:
    > - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
    > - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
    > - argument for rectangle() given by name ('color') and position (3)
    > - argument for rectangle() given by name ('color') and position (3)

    • @crezebeki
      @crezebeki 2 роки тому

      I got this error. But it was an error in this line:
      wrong => bottom_right = (top_left[0], needle_w, top_left[1] + needle_h)
      correct => bottom_right = (top_left[0] + needle_w, top_left[1] + needle_h)
      i'm also on OpenCV(4.6.0)

  • @amardeep100
    @amardeep100 3 роки тому

    Hey man nice video. I was hoping if a make video on playing gta 5 using hand recognition and open cv. Thanks 👍

  • @BearcatJamboree
    @BearcatJamboree 2 роки тому

    Does OpenCV and PyAutoGUI have the ability to fuzzy match images in a recording instead of real-time game play? My use-case is looking for one of several character faces in a game and capturing a few seconds before and after if was found.

    • @BearcatJamboree
      @BearcatJamboree 2 роки тому

      nvm I saw your other video on templatematch and I'm coding with that plus face detection. thanks for providing these videos!

  • @มานิตย์สุทธิผล-ฏ4จ

    ความรู้ทั้งนั้นขอบคุณมากครับ

  • @chuntatngai469
    @chuntatngai469 4 роки тому +1

    THanks for the great content. How did you get few lines of code without typing? Is this a snippet function available in Visual Studio only? Much appreciated for reply. :D

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому

      I tried all this out before filming, so I copy pasted some code from that. I also edited out some of my typing. I figure since this tutorial is more advanced you guys probably don't need to see me type everything out and would rather have a more concise video.

    • @chuntatngai469
      @chuntatngai469 4 роки тому +1

      @@LearnCodeByGaming oh thanks Ben. I have used Visual Studio for C and C# before, I had used some of the snippets, which led to my confusion.Thanks for your explanation. They are very clear for more experienced programmers and beginners.

  • @pinguio
    @pinguio 4 роки тому +5

    Awesome tutorial!
    I have an issue. I have tried with other immages and when I run the script I get this error: (-215:Assertion failed) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims()

    • @LearnCodeByGaming
      @LearnCodeByGaming  4 роки тому

      Thanks! That error usually means the image you are passing into matchTemplate() isn't a valid OpenCV image. Check the file path you're passing into imread() and make sure it's correct.

    • @pinguio
      @pinguio 4 роки тому

      @@LearnCodeByGaming Thanks, I will check! 🙂

    • @quanzhenj3252
      @quanzhenj3252 3 роки тому

      I have installed opencv -python 4.5.1.48 , I copied your code and just change the picture names, the files are in same projects folder, and I got the same error he got , -215 assertion failed

    • @ericsein
      @ericsein 3 роки тому

      Also got this error, the path to the image was wrong.

    • @AverageTV
      @AverageTV 3 роки тому +8

      @@ericsein I solved it. You just have to change im.READ.UNCHANGED to 1 for unchanged or 0 for grayscale. There is a list on the cV side wich number what represents

  • @RK-de3uu
    @RK-de3uu 3 роки тому

    thanks for the clear explanation!