Self-driving Car – Python plays Grand Theft Auto 5 p.7



As I was contemplating the next steps, I was curious about a couple of choices for Artificially Intelligent driving. One thought I had was that we could detect both lanes, and then attempt to orient the car in between the two lanes, so long as those two lanes had different slopes.

…then I began to think about it, and wondered if the problem coudl be even more simple than that. I noticed that the times when the lanes would “both” be on one side or the other was when we were getting to…

Related Posts

36 Comments

  1. Huh. This doesn't work nearly as well for me, though I think it's down to the lane finder more than anything. Odd, since I used your code.

    Also, I'm super confused! I can't figure out why you should go left when both m's are negative and vice versa! Surely, if both slopes are negative, i.e. going from the bottom right to the top left, it means it can't see the middle of the road and so we're too far right, and should go left, no? And so if both are positive, we should go right?

    Thank you!

    EDIT: Never mind! So it was two things. One was that the values for the line threshold either are changed off cam or I just missed them, and the other is that the road really matters. I found a stretch after loads of searching that had the double yellow solid line and it worked waaaaay better than on the road I was trying. Thanks again!

  2. Have you thought about taking the abosulte values of the m's as an indication of how much throttle/break to apply. If the m's are high, you have steep hughs, which means you can put your foot down… Shallow gradients means apply the break… Maybe consider the abs of the lowest m, or the highest, or the avg, or some such…

  3. Amazing series, loving it so far, and the best part is it has given me a lot more confidence in my programming skills as I'm usually too pessimistic and/or scared to give complex tasks a go. I've been interested in getting to know OpenCV for a long time, hopefully I'll crack it one day. Easily earned my subscription

  4. Anyone using Burnout Paradise City? It is not detecting the yellow lanes in the middle for me, also the dotted lines. I tried to play around with game's settings, the blur and Hough lines but to no avail 🙁 Could anybody please help me? The car won't turn also but I think that's because the lane detection is not perfect.

  5. do you have a copy of this exact version as shown in the video? i would like to test it on other games as i know that it detects the lanes. i know that this is a very basic version that is not specialized for specifically gta V

  6. For anyone else confused with the slopes of the 2 lines being positive/negative for turning directions, note that CV2 defines right and down to positive directions. Then it should make sense to you!

    Also, @sentdex, I have been trying your algo on some different road, and finding it highly situation dependent. That is — it works quite well on some roads and works terribly on others 🙂

  7. i barely know anything about coding but is there a way where you can look at the code of an AI taxi driver as to how he corrects the movement of the vehicle which turn to take and so on so forth or would it be different.

Leave a Reply

Your email address will not be published.

© 2022 Code As Pro - Theme by WPEnjoy · Powered by WordPress