Line Finding with Hough Lines - Python plays Grand Theft Auto 5 p.5

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

КОМЕНТАРІ • 75

  • @Macadoof
    @Macadoof 7 років тому +198

    "Wow that guy just totally went around me, what a prick!"
    *sits on parked scooter in middle of the road*
    On topic though: loving this series.

    • @sentdex
      @sentdex  7 років тому +63

      I could have been stopped for a kitten, that driver has no idea!

    • @7characters
      @7characters 7 років тому +3

      I laughed out loud

  • @АйданаАбдыкеримова-г2и

    thanks, Edward Snowden

  • @Mezklador
    @Mezklador 7 років тому +2

    I've loved the way you describe "blur" algorithm! Like a nervous washing board with hands... Really creative one! Bravo.

  • @shivarao193
    @shivarao193 6 років тому +5

    Man, this thing is going to be my major project .... thanks sentdex you are great

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

    thank you for the great job ! just started learning python because of this series .. please keep doing these video-game-related things

  • @MarkJay
    @MarkJay 7 років тому +20

    have you tried preprocessing with a blur filter before the canny edge function? the cv2.BilateralFilter is a good choice because it preserves edges while smoothing out irregularities. It can be a bit cpu intensive though.

    • @MarkJay
      @MarkJay 7 років тому +16

      Damn, made this comment before finishing the video. doh!

    • @sentdex
      @sentdex  7 років тому +15

      hahaha

  • @Vicininater
    @Vicininater 6 років тому +3

    In general, blurring comes before edge detection. The method you used is commutative so it doesn't matter, but a bilateral filter (which preserves edges) is not; and therefore you'd just end up with blurry lines instead of sharp ones.

  • @carbon13
    @carbon13 7 років тому +1

    Just a quick note:
    The array of array thing makes more sense in C++, as most of the functions returned cv::Mat, a 2D array. So the output of HoughLines was a n x 1 array (where n is the number of lines), but the datatype was cv::Vector2f (a struct of two floats). As the Python version is just a wrapper, it still makes sense to return in the same format.

  • @MisterDidactic
    @MisterDidactic 7 років тому +7

    Hey Harrison, I don't know if you've done this yet but turning off head bobbing in first person might help things slightly in any number of ways

    • @sentdex
      @sentdex  7 років тому +7

      I wasn't aware we could turn off head bobbing.

  • @fuba44
    @fuba44 7 років тому +10

    Simple improvements to performance could be to only print out every 100'th time and do an average, and maybe only draw the 10 longest lines. (maybe by sorting the list on lines) and I'm sure some way smarter things that you will show me... In the next video that I will watch right now!

    • @poseidon4675
      @poseidon4675 7 років тому

      fuba44 that's actually a pretty good idea..! I like it

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

    how did python recognize line[0] as coordinate that must be lined to another vertice?
    and, how did it know coords [1,2,3,4] as x1,y1,x2,y2 ?

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

    I binge watched the entire series in a night. I'm rewatching it. Netflix might as well buy this from you. Also, kindly check your ig handle. I dm'ed you there. Big fan, Sir

  • @VincentChartrand
    @VincentChartrand 7 років тому +15

    8:25 fuck me
    Instead of try/except, I would do:
    if not lines:

    • @sentdex
      @sentdex  7 років тому +14

      hahahhahaha, but my try/except sin felt so good. It should be your way though, no arguing with that.

    • @shmuel-k
      @shmuel-k 7 років тому +6

      I said noooo out loud before you said "fight me"

    • @noctreik
      @noctreik 7 років тому

      He said bite me ;p

    • @vobjects
      @vobjects 7 років тому +2

      Good ol' On Error Resume Next

    • @aquarium778
      @aquarium778 7 років тому

      i think he said fight me

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

    If someone gets a NoneType, it means that there are no lines that can be drawn. You will have to put a "if lines is not None:" above the draw_lines

  • @JoshFish11
    @JoshFish11 7 років тому

    Lines are everywhere on the screen but there are only 2 large spaces without any lines: the road and the sky. Might that be a better way of road detection?

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

    8:19 how u did that spacing thing, I mean what's the shortcut key for that.

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

      Tab and shift+tab

  • @samwoodfield7332
    @samwoodfield7332 5 років тому

    My question is, using both visual input and collected user input, could an AI with recursive learning work out how to play games based solely on viewing and understanding or emulating user data for certain situations? Technically, your project puts us half way there?

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

      You still have to give it goals, as in things for it to try to accomplish (via weights on outputs) but yes, there have been projects that have done just that. As I understand it some of Google's DeepMind projects (DOTA gaming) trained this way.

  • @kplays_6000
    @kplays_6000 7 років тому +1

    What are your graphic settings? Mine isn't detecting as many edges as yours, and I suspect it may be due to some settings to do with anti-aliasing, and I'm worried in the future it may affect the performance of the AI on my end.

    • @sentdex
      @sentdex  7 років тому +2

      You can either mess with the settings in GTA, or just mess with your houghlines/blur functions. The anti-aliasing would only help improve line detection, but blur also does the same thing for our purposes. I was running gta in ultra, but recently put everything to minimum, and didn't notice any differences.

  • @blakeortiz277
    @blakeortiz277 6 років тому

    with the "processed_img = " lines in the "process_img" function, those are just attributes you're giving to the "processed_img" correct?

  • @edguix
    @edguix 6 років тому +2

    first time i heard hough the way you say the name hugh. i always heard it pronounced it huff in school.

    • @sentdex
      @sentdex  6 років тому +1

      I'm probably saying it wrong

  • @TheSiggs1
    @TheSiggs1 7 років тому +1

    For some reason im only detecting one thing at a time, am I missing something as to detect multiple lines?

    • @sentdex
      @sentdex  7 років тому +1

      Maybe a subtle difference in code, compare your code to mine: pythonprogramming.net/hough-lines-python-plays-gta-v/

  • @zaidangaming1288
    @zaidangaming1288 6 років тому

    This guy is like God to me.
    much respect from Pakistan. 🙌

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

    hi, I don't think after using Gaussian blurring, the image will look like yours' image. And my experiment just likes what I said.

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

      I think that blur is just used to smoosh the edge wouldn't widen the line.

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

    hello i want to find rotation angle of my image using opencv python can you help me out...!

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

    I keep running into "TypeError: 'NoneType' object is not iterable"

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

      oh i think it just breaks when it stops finding lines

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

      try doing this on top of the for loop in the function: if lines.any() != None:

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

    I am getting this error can someone help:-
    Traceback (most recent call last):
    File "C:/Users/poorn/PycharmProjects/Poornith/Poornith.py", line 27, in
    new_screen = process_img(screen)
    File "C:/Users/poorn/PycharmProjects/Poornith/Poornith.py", line 21, in process_img
    lines = cv2.HoughCircles(processed_img, 1, np.pi/180, 180, 20, 15)
    cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\hough.cpp:2318: error: (-5:Bad argument) Unrecognized method id. Actually only CV_HOUGH_GRADIENT is supported. in function 'cv::HoughCircles'

  • @osamansr5281
    @osamansr5281 6 років тому

    def HoughLines(image, rho, theta, threshold, lines=None, srn=None, stn=None, min_theta=None, max_theta=None)
    i think the problem is u missed and miss used the "lines=None" parameter :D .. and lol great tutorials, u sometimes do stuff off screen but i like the way u teach us :D ,, THANKS

    • @osamansr5281
      @osamansr5281 6 років тому

      check the answer here : stackoverflow.com/questions/35609719/opencv-houghlinesp-parameters

  • @abdulbakiaybakan8836
    @abdulbakiaybakan8836 7 років тому

    I am doing this with GTA Vice City but I cant see the lines maybe because the lines are not so bright as GTA 5. what would you suggest me to do for that?

  • @akshaypatti3423
    @akshaypatti3423 6 років тому

    Hey, I am trying out the same for practice. Can anyone please help me find the location in the game where the video is shot? Coz other locations have a lot of disturbance but the one used in the video seems to be quiet.

    • @Rnjeazy
      @Rnjeazy 6 років тому

      Blaine county. Somewhere near Trevor's trailer.

  • @oneplusonetwo
    @oneplusonetwo 7 років тому

    why not pick out the yellow line in the middle of the road base on color first(so you dont need to deal with trees), useing HSV(or HSB, basicly the same thing with different name) mode should be preferable, idk if cv2 has fuction like RGB2HSV, if it has then fill the yellow pixels(hue around 40, plus minus 10 maybe) with white(or leave it as is) and the rest with black
    also why not do the crop or region of interest first, should make the rest process much faster

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

    Probably a boxfilter is enough and faster for this purpose

  • @acermf7983
    @acermf7983 5 років тому

    Does anyone know how to find moving circles?

    • @emin86
      @emin86 5 років тому +1

      I'd say search google for OpenCV Guitar Hero. There would be a code that might help ya?

  • @kld0093
    @kld0093 5 років тому +1

    this is epic

  • @Kage1128
    @Kage1128 7 років тому +1

    HOW DO I GET MORE THEN 1 FPS ON MY CAPTURE
    !?!?!?1 I HAVE GTX 1080 AND 6700 INTEL

    • @Rnjeazy
      @Rnjeazy 6 років тому +1

      Mine's a GTX 1070 with 6700 and works smoothly for me so far. Look at part one of his tutorial. That might help.

  • @Triggerboy78
    @Triggerboy78 7 років тому +1

    you did some blurred lines here

  • @persimon_wav
    @persimon_wav 7 років тому +4

    Hi! Great channel!
    I had the same problem with the line finder where it didn't quite respond to me changing the parameters. I found this stackoverflow thread which seems to solve it:
    stackoverflow.com/questions/35609719/opencv-houghlinesp-parameters
    The problem appears to be that the parameters are read differently than in the documentation so call the function with the parameters like so:
    lines = cv2.HoughLinesP(edges, 1, np.pi/180, threshold=200, minLineLength=20, maxLineGap=5)

  • @patrickhentschel5300
    @patrickhentschel5300 7 років тому

    anyone noticed he is doing exactly the udacity course on autonomous driving? even the code its the exact same with same function names like draw_lines and process_img

    • @sentdex
      @sentdex  7 років тому +6

      I don't think udacity invented the grayscale > canny > roi > houghlines workflow for lane detection. Would be happy to attribute them if that was the case. A quick google search for how to find lanes with python and open cv seems to suggest this is pretty standard procedure.

    • @patrickhentschel5300
      @patrickhentschel5300 7 років тому

      sentdex Damn then i wasted my money there i really like your videos. you are way more entertaining to watch

    • @sentdex
      @sentdex  7 років тому +12

      Nah, I really doubt we're ...going down the same road... *chuckles to self* I expect the Udacity course took a more serious and realistic approach to self-driving cars. I intend to do no such thing, we're gonna go a bit wild with it. I'm really more interested in the general AI aspect than anything else as well. So far by the end of part 13, I've got a motorcycle that races through traffic, and I've begun testing evading police. I suspect Udacity taught you to stay in between the lines. ;)

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

    Hey, how can I get your desktop wallpaper?

  • @_-will-_3313
    @_-will-_3313 7 років тому +1

    2:10

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

    It is pronounced like "huff" kinda like tough.

  • @codedragon6237
    @codedragon6237 7 років тому

    Really, 3 pixels thick is not very neat.

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

    Hough = pronounces "Huff"

  • @ParallaxScene
    @ParallaxScene 7 років тому +8

    It hurts to watch you do a lot of the processing before the mask.

    • @sandeeptadepalli5963
      @sandeeptadepalli5963 7 років тому +11

      uncensored videos help us to understand ur thinking process. nice work bro thank you

  • @m3n4lyf
    @m3n4lyf 6 років тому

    I play VAPOR WAVE to my BITCOIN investments, Hough Lines of FORTRAN all day & do hacker stuff