Self-Driving Cars in Python

Isn’t it beautiful that having only a computer, internet connection and some software skills you can learn and develop things which relate to the most cutting-edge technologies today? And I don’t mean only pure software business like web services, social media or mobile apps. With a bit of dedication and persistence you can enter to the world of robotics, AI, VR or… Self-Driving Cars.

And yes, you can do it with Python which is widely used today and not so hard to learn! Maybe in real applications used in autonomous cars C++ is the dominating language but Python is also popular as it’s very fast for prototyping and there are many free libraries available. The community around this topic is growing and there are some interesting projects you can track. To mention only some of them, there is a simulator of autonomous driving in the world of GTA V. There is also a project where Python code is embedded in Raspberry Pi – the board is attached to a small model car which can be run in artificial environment. There are even challenges published by Udacity or Didi where you can contribute to open-sourced projects which ends finally in running it on a real car!

Udacity course

After a long break of blogging I’m going to publish a series of posts about my side projects which are all related with autonomous cars. I’m on a good way to finish the Udacity course “Self-Driving Cars Engineer” – term 1. The goal of the whole nanodegree is to prepare a student to get a job in companies producing solutions for autonomous vehicles. This complex domain of technology is very hot now and every major car maker has a division to develop own methods in that field. It’s very exciting that projects you deploy during the course might be potentially used in a car equipped with cameras, radars or lidars. Besides, what attracted me the most to join the course was opportunity to develop my skills in Computer Vision, Convolutional Neural Networks, Python language and related libraries which are commonly used for Machine Learning.

Udacity Car

Throughout the series of posts following projects will be described:

  1. Lane Lines Finding
  2. Traffic Sign Classification
  3. Behavioral Cloning
  4. Advanced Lane Finding
  5. Vehicle Tracking and Classification

Technology Stack

All projects will be implemented in Python with the use of popular libraries like OpenCV, Tensorflow and Keras. Image processing methods should be helpful like Edges Detection, Hough Lines Transform or Histogram of Oriented Gradients. Deep Neural Networks will be utilized mainly for projects 2 and 3. To increase DNN training speed I will use AWS instance with GPU as the main processing unit. The code will be nicely presented in Jupyter Notebook where you can observe what was produced after each code block. Finally, the code will be stored on GitHub.

Self-Driving Cars industry

The dream about letting cars drive themselves is not so fresh. It’s depicted on a heading picture from 50’s and is present in many science fiction Hollywood productions. The motivation behind the concept is to eliminate danger on a road by reducing human errors. If vehicles have also smart communication between them they can predict threats or design the optimal route more efficiently. Moreover, such cars could be used when you are at work and even make money for you offering a journey to others. Some tests have been conducted already in the last century, mainly in USA and Germany [1]. In 2004 DARPA (the Defense Advanced Research Projects Agency) announced the “Grand Challenge” which was a big breakthrough in this research field. 1 million dollar prize was funded for the winner who create an autonomous car which will be the fastest on a defined 150 mile road accross the Mojave Desert. Universities and private teams competed and many of these engineers, like Sebastian Thrun or Anthony Levandowski later became key inventors in Google and other companies building self-driving systems. I strongly recommend the following documentary about this contest.

Later, companies like Google and Tesla started seriously investing in their commercial self-driving cars. Law in California became more friendly for companies and startups from the industry. So far, to test autonomous cars, a human driver is legally required to be present and ready for unexpected car behaviour. It’s where we are in general – so-called Level 2. Of course, everyone is aiming ultimately to land in Level 4 meaning that we could chill out, read or even sleep during a journey.

Levels of technology advancement


Many companies are competing to be the first to achieve the highest level of technology. Except the two already mentioned ones, following companies are active in the business which is very dynamic with many acquisitions and collaborations:

  • Uber – acquired Otto, cooperating with Mercedes/Volvo/Ford
  • Ford – investing in
  • Bosch – collaborating with Nvidia
  • Didi
  • Intel – bought Mobilye, cooperating with BMW
  • Valeo
  • Baidu
  • General Motors – bought Cruise Automation

Below, you can see an exemplary, real-world implementation of the developed system by Nvidia riding a Lincoln car.


[1] History of autonomous cars – Wikipedia

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.