OpenCV - Python plays Grand Theft Auto 5 p.2

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 110

  • @soumen_das
    @soumen_das 7 лет назад +37

    This series is gonna be the coolest yet.

  • @ayushthada9544
    @ayushthada9544 6 лет назад

    I don't know why I haven't across your channel yet. Your channel is the best thing. I have not seen something like this before.

  • @WiggumRalph
    @WiggumRalph 7 лет назад +55

    I've been looking for a LinusTechTips of Software and i found new favourite channel. :D

    • @sentdex
      @sentdex  7 лет назад +7

      Welcome good sir!

  • @aug_st
    @aug_st 7 лет назад +70

    That's not how CPUs/GPUs work :p The CPU cannot play GTA at ~10FPS, but can capture the desktop at 10FPS. The GPU is still being used to render the entire game at probably over 60FPS. Basically, 10FPS is how fast the GPU can copy over its framebuffer to the CPU/RAM and do some processing.

    • @jlewwis1995
      @jlewwis1995 7 лет назад +5

      Parad0x0217 I'm sure Python is adding some overhead to the process as well being an interpreted language and what not.

    • @dannykong944
      @dannykong944 7 лет назад +2

      Complete sidebar when my nvidia drivers bricked without me realizing I still got 6-7 frames on my i5's integrated graphics

    • @Stojke1001
      @Stojke1001 6 лет назад

      Danny Kong He wasnt talking abou igp on the proccesor, he was talking about the proccesor itself rendering the game
      EDIT: Which is kind of false, CPU is just displaying it on the CV

    • @Sevcen23
      @Sevcen23 5 лет назад

      @@jlewwis1995 also, python can run on one core only, so it's still quite impressive.

  • @amitmauryathecoolcoder267
    @amitmauryathecoolcoder267 5 лет назад +2

    Bro, you are a God level programmer and I wish to be like you .
    Cool , humble Guy....
    Really , Enjoyed your each and Every video....
    You are freaking Awesome................................

  • @rokkanroull
    @rokkanroull 7 лет назад +26

    cv2.Canny automatically converts the passed-in image to grayscale (according to the documentation), so you're basically calling cv2.cvtColor twice ;)

    • @sentdex
      @sentdex  7 лет назад +20

      Damn, you're right. Thanks for this correction.

  • @herantd
    @herantd 7 лет назад +11

    if you ever going back to computer vision instead of neural network, try using mss instead of pillow for screen grab, it gives a lot better fps.

    • @constantincolac1993
      @constantincolac1993 5 лет назад

      Amazing how much more performant it is! Thanks for sharing this.

  • @MsLemons12
    @MsLemons12 7 лет назад

    You legitimately read my mind. I was looking for a good tutorial for this last night!

  • @lpvillazon
    @lpvillazon 7 лет назад +1

    Is edge detection the best way to find the road lanes? Wouldn't something that looks for large blocks of similar colour be more effective? I don't have any experience with neural networks, I'm just curious.

  • @industrialdonut7681
    @industrialdonut7681 4 года назад

    that edge detection looked so cool

  • @AMNevesGaming
    @AMNevesGaming 6 лет назад +4

    "you cant just throw neural networks at things" TRY ME! jokes aside this is what im doing now to learn :v

  • @serveladik
    @serveladik 7 лет назад +9

    What is 0xFF doing?

    • @Diadochokinetic
      @Diadochokinetic 4 года назад

      oscarliang.com/what-s-the-use-of-and-0xff-in-programming-c-plus-p/

  • @rockyrivermushrooms529
    @rockyrivermushrooms529 7 лет назад +4

    amazing stuff. Im like a caveman when it comes to programming! I use a raspberry pi when practicing

  • @peterwood6875
    @peterwood6875 7 лет назад +1

    I wonder whether it would be useful to apply a wavelet transform after reading the image in order to represent it in a more efficient low-dimensional way. A wavelet transform could dramatically reduce the dimensionality of a representation of an image, which is why they are used in image compression. Maybe that would help with training the neural network more quickly or improving the speed on the AI.

  • @rockyjain1555
    @rockyjain1555 5 лет назад +1

    To solve 8:23 this #largewindowissue add three lines before while loop
    from ctypes import windll
    us32=windll. user32
    us32. SetProcessDPIAware()
    While True.........

  • @wolfrig2000
    @wolfrig2000 4 года назад

    your fix at 8:30 is off screen, what was it you changed to fix the error?

  • @EduardoME
    @EduardoME 5 лет назад

    It is possible to get the video feed from nvidia shadowplay? They save a temp file when recording

  • @WhyUMadNomad
    @WhyUMadNomad 7 лет назад +1

    The threshold2 of 300 doesn't make sense cause there will never be a pixel with a value greater than 300, right? The max is 255.

  • @AmCanTech
    @AmCanTech 7 лет назад +2

    How did you get gta 5 running? I would like to follow along with the tutorials. Also, thought you said candy edge detection, that would be a fun algorithm

    • @jlewwis1995
      @jlewwis1995 7 лет назад +1

      AmCan Tech Videos Candy Edge Detection Saga ;)

    • @AmCanTech
      @AmCanTech 7 лет назад +1

      Haha. I should work on that, just for the hell of it.

  • @naveensoni5150
    @naveensoni5150 7 лет назад +1

    i m getting this error ..
    Traceback (most recent call last):
    File "C:/Users/nsoni/Desktop/1.py", line 19, in
    process_screen = process_img(original_img)
    NameError: name 'original_img' is not defined
    >>>

    • @usmani93
      @usmani93 7 лет назад +1

      the code is process_screen = process_img(screen)
      the argument given to the process_img function should the screen we are capturing,

  • @rokutata
    @rokutata 7 лет назад +2

    I have a problem with PyAUtoGui, i am using windows python34
    I did pip install pyautogui, everything was ok
    When I open cmd, write python, and doing import pyautogui everyting is ok,
    But when I am launching your scripts it gives me error:
    File "part-2-and-3-keyboard-input-and-basic-OpenCV.py", line 5, in
    import PyAutoGui
    ModuleNotFoundError: No module named 'PyAutoGui'

    • @sentdex
      @sentdex  7 лет назад

      You don't NEED pyautogui. I am only using it because for some unknown reason it resizes my window proportionally and that's helpful for recording. You can just not import it.

    • @rokutata
      @rokutata 7 лет назад

      Thanks

  • @sneh269
    @sneh269 4 года назад +1

    my windows refreshes so fast , it stays gray and goes into not responding

  • @erfantaghvaei3952
    @erfantaghvaei3952 4 года назад +2

    I wish you were my professor at college :(
    One question man can we implement the YOLO object detection algorithm on this too ?

    • @sentdex
      @sentdex  4 года назад +1

      I dont think so, yolo is object detection, not object recognition AFAIK.

  • @python1108
    @python1108 4 года назад

    How do you decide the thresholds for Canny?

  • @robertpietraru1939
    @robertpietraru1939 4 года назад +1

    Fun fact: gta is free now so this is useful now

  • @abdelazizmegdiche2542
    @abdelazizmegdiche2542 7 лет назад

    hey thanks for the tutorial .I greatly enjoy your videos.Could you please do a special on using the Aruco module with opencv python or making your own bindings 'cause I think this might only be available in C++ and I kinda need ot for project (meaning all my work is based and I need it ready for next week ) you'd really help me out

  • @dosonleung536
    @dosonleung536 6 лет назад

    if just gray mode, how to recognize the traffic light?

  • @MuffinMystery
    @MuffinMystery 7 лет назад

    Hey, do you know where I can get PIL for 3.4 onwards? I looked around but couldn't find a download for the right version.

    • @sentdex
      @sentdex  7 лет назад +1

      I would use: www.lfd.uci.edu/~gohlke/pythonlibs/#pil

    • @MuffinMystery
      @MuffinMystery 7 лет назад

      Thanks :D

  • @Cygnus0lor
    @Cygnus0lor 6 лет назад

    6:04 that was an April fool's joke xD

  • @urbanequipment
    @urbanequipment 7 лет назад +2

    Hey man, Lovin your work!!
    ps where do i get cv2/openCV from?

    • @sentdex
      @sentdex  7 лет назад +3

      pythonprogramming.net/loading-images-python-opencv-tutorial/, grab the appropriate wheel file for your setup from: www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
      For example:
      opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl is opencv version 3.2, for python 3.6, and amd64 means your version of Python is 64bit.

    • @urbanequipment
      @urbanequipment 7 лет назад +1

      Thanks heaps dude!!! Keep up the great videos!

    • @rban123
      @rban123 5 лет назад +1

      use pip

    • @LabGecko
      @LabGecko 3 года назад

      What @Ryan Bandler said. This worked for me just a few days ago (using Python on Win 10).
      pip install opencv-python

  • @nano7586
    @nano7586 6 лет назад

    Oh man, i really don't know how to program (just did a simple course) but this is so fascinating.. and so far it's "easy" to understand the basic behind it (let's find out if i can stick to that :D)

  • @akcricketlive6029
    @akcricketlive6029 6 лет назад

    Can I practice this on NFS rivals?

  • @OZtwo
    @OZtwo 3 года назад

    The question is will GTA run on a Jetson Nano 4G (B01)? :)

  • @dreadnought4177
    @dreadnought4177 6 лет назад +1

    What do I do at at 8:11 you don't show it!!!!

    • @deadlock107
      @deadlock107 6 лет назад

      cv2.imshow("window", new_screen)

    • @neven3030
      @neven3030 5 лет назад

      it's late but: new_screen = process_img(screen) new_screen = process_img(original_image)

  • @hydroblitz3307
    @hydroblitz3307 6 лет назад +1

    Video summary
    We created blind gtav

  • @fanel1900toamna
    @fanel1900toamna 6 лет назад

    You can use code like this to draw the FPS on the image (to avoid the call to `print`):
    def draw_fps(image, frame_duration, position=(20, 20),
    font=cv2.FONT_HERSHEY_SIMPLEX, font_size=.5, text_color=(255, 255, 255)):
    text = 'FPS: {0:.2f}'.format(1 / frame_duration)
    cv2.putText(image, text, position, font, font_size, text_color)
    ...
    # Print FPS
    frame_duration = time.time() - last_time
    draw_fps(image, frame_duration)
    last_time = time.time()

  • @Liam-e6q
    @Liam-e6q 6 лет назад

    Getting the following error:
    ModuleNotFoundError: No module named 'PIL'
    whilst importing ImageGrab from PIL
    please help :p

    • @angel-ig
      @angel-ig 4 года назад +1

      Use 'pip install pillow' in your terminal.

  • @appa609
    @appa609 4 года назад

    You get about 30% better performance if you move the cvtColor from imshow to the assignment of screen.

  • @pranavnigam11
    @pranavnigam11 3 года назад

    6:02
    Uhh I'm pretty sure you're referring to NVIDIA's April Fools prank 😅

  • @jacobdavidcunningham1440
    @jacobdavidcunningham1440 7 лет назад

    Why does it take so much training data I wonder, I mean a human you're like "do this" once or twice and boom you've got a peasant washing plates for a living. Cool series learning a lot following. Also the human vs. computer question is rhetorical.
    edit: dumb question this isn't entirely on the fly right as you make the video? You've got another screen that you're looking at for reference, it seems like it, but regardless if Python is one of your primary languages then it makes sense to be so comfortable using it. I'm trying to follow the camelCase syntax where/when also the lack of semi-colons in Python is interesting.

    • @niter43
      @niter43 7 лет назад +2

      Jacob David Cunningham if you ask a baby to wash plates he wouldn't even understand you. Our skill to learn simple tasks quick is result of years of training.

    • @jacobdavidcunningham1440
      @jacobdavidcunningham1440 7 лет назад

      I don't know if when you say baby it's because of AI/Machine Learning's relatively early age or what... I obviously wasn't talking about babies if you can't understand English/language even that humans are visual you could show someone in another language by gesture how to do something but sure. As I mentioned my question isn't really a question.

    • @jacobdavidcunningham1440
      @jacobdavidcunningham1440 7 лет назад +1

      The other thing is instinct. Isn't it cool how spiders know how to make a web without being taught how to weave one. I'm pretty sure they are not taught how to ie. a lone spider will figure out how to make a web. Also how deer can walk immediately when they're born versus humans that take possibly years.

  • @GibsnRage
    @GibsnRage 7 лет назад

    YESSS SENTDEX I LOVE YOU

  • @Vethane
    @Vethane 7 лет назад +1

    it says original_img not defined

    • @randomguy4460
      @randomguy4460 6 лет назад +1

      change line to - new_screen = process_img(screen)

  • @themilestonelp1524
    @themilestonelp1524 4 года назад

    Did he fall for the nvidia ai stick thing?

  • @antoniokaram8189
    @antoniokaram8189 7 лет назад

    how do u resize you gta screen so much?!

    • @sentdex
      @sentdex  7 лет назад +2

      Change resolution in settings.

  • @knezivan1
    @knezivan1 5 лет назад

    g4560 will it work hmmmm

  • @koolaidmangiggity
    @koolaidmangiggity 7 лет назад

    wouldn't cv just be coping the image rather than rendering them like the gpu is?.

    • @sentdex
      @sentdex  7 лет назад

      I assume this is in response to my "the cpu is running GTA V." You're right, the CPU is just simply "displaying" the updating data, not actually doing any physics calcs...etc.

  • @pradeepkumar-qo8lu
    @pradeepkumar-qo8lu 7 лет назад

    is there a way where the image processing is done in c++ and the processed data is passed onto python??

    • @sentdex
      @sentdex  7 лет назад +3

      It's my understanding the OpenCV is C++, and we're just simply using a Python wrapper with it when we import and use cv2. I could be wrong here.

    • @pradeepkumar-qo8lu
      @pradeepkumar-qo8lu 7 лет назад

      sentdex even I don't know,heck I'm just getting into programming but its just a hunch given the fact that it takes a fair bit of time to call the c routines then convert to Python code.So if there's any library or something which would enable people to use 2 totally different environments without the hassle of converting it to one form to another

    • @vimal1083
      @vimal1083 7 лет назад

      @sendex, Your'e correct opencv-python is just a python wrapper for openCV C++ library

  • @SamoSkywalker
    @SamoSkywalker 6 лет назад

    Your tutorial is so clear.Thanks,I have learned a lot after watching your video.I want to ask for your permission to translate your video into Chinese and upload to some domestic websites of course I will put your channel link on..Because my country doesn't allow us to visit RUclips and not everyone is able to get a VPN.I'm waiting for your reply and it's ok if you don't want me to do this.

  • @renzthecarry2057
    @renzthecarry2057 7 лет назад

    wow, que bacan sentdex!! eres lo maximo.. i want to make something similar with League of legends! =D

  • @bennis9283
    @bennis9283 7 лет назад

    this will be so awesome :D

  • @maianhtu0105
    @maianhtu0105 3 года назад

    Many thanks

  • @easter.bunny.6
    @easter.bunny.6 7 лет назад

    8:56 funny laugh bro lmao

  • @dlhg7287
    @dlhg7287 7 лет назад +1

    if you have a linux computer, imagegrab won't work

    • @YoloMonstaaa
      @YoloMonstaaa 7 лет назад

      Well he's playing GTA so obviously he's on windows.

  • @sho3bum
    @sho3bum 7 лет назад

    Can I do this in linux?

    • @sentdex
      @sentdex  7 лет назад +1

      if you can get GTA V running on linux, then yes. It's possible, but I've never bothered with doing that.

    • @sho3bum
      @sho3bum 7 лет назад

      So I don't have windows, my laptop runs ubuntu, but if I had windows it would have run GTA 5. So, my main issue is whether the fact linux can't run games is going to be a factor?

    • @2003vito
      @2003vito 7 лет назад +1

      you should install windows and thats it

    • @sho3bum
      @sho3bum 7 лет назад

      Thanks.

    • @YumekuiNeru
      @YumekuiNeru 7 лет назад +1

      you could do it for a different game that Linux can run if this one will not, I have no idea. There are many that run natively, and many more that will work well in wine.

  • @woahcarlos1611
    @woahcarlos1611 5 лет назад

    I love converting to cray

  • @stuffenjoyer
    @stuffenjoyer 7 лет назад

    Lovin it

  • @brucebane7401
    @brucebane7401 4 года назад

    this is the best

  • @viktorvlasov483
    @viktorvlasov483 7 лет назад

    damn, it's a good idea.

  • @jlewwis1995
    @jlewwis1995 7 лет назад

    There is a game on the N64 that has a cheat code that allows you to use a sort of black and white edge detection rendering algorithm like the one in this vid to play the game, honestly it is complete eye cancer because the blank areas are white instead of black :/ Also it lets in some texture on some surfaces so it's not really true edge detection but oh well I don't think that's what it's point was anyway

  • @NatanSalazar
    @NatanSalazar 6 лет назад

    my ryzen 5 1400, 8gb ram 2666mhz and rx 550 runs like you the script (not the GTA V, of course, but the script runs like yours)

  • @shahidkhan0219
    @shahidkhan0219 7 лет назад

    You are awsome

  • @yashwanththota7543
    @yashwanththota7543 6 лет назад

    i am getting multiple windows

  • @reghunaathaa1654
    @reghunaathaa1654 4 года назад

    Using mss library I got 30 fps

  • @hyperunstable9397
    @hyperunstable9397 5 лет назад

    your awsome XD

  • @crash_override9435
    @crash_override9435 5 лет назад

    Had a better time once I hit mute. Entertaining content. Thanks for the inspiration.

  • @austinelms6658
    @austinelms6658 6 лет назад

    :)

  • @snarkyboojum
    @snarkyboojum 7 лет назад

    OpenCV isn't playing GTA though, is it? It's just taking screengrabs and displaying them back. Not that impressive on the CPU is it? :)