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

Поделиться
HTML-код
  • Опубликовано: 13 дек 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

  • @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

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

    thanks, Edward Snowden

  • @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

  • @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.

  • @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.

  • @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

  • @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

  • @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

  • @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.

  • @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 ?

  • @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

  • @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.

  • @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

  • @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?

  • @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?

  • @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

  • @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/

  • @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?

  • @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.

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

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

  • @pratikgurav727
    @pratikgurav727 2 года назад

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

  • @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

  • @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:

  • @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.

  • @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'

  • @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.

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

    Probably a boxfilter is enough and faster for this purpose

  • @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

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

    this is epic

  • @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?

  • @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. ;)

  • @_-will-_3313
    @_-will-_3313 7 лет назад +1

    2:10

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

    It is pronounced like "huff" kinda like tough.

  • @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

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

    Hey, how can I get your desktop wallpaper?

  • @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