In this project, the goal is to write a software pipeline to detect vehicles in a video project_video.mp4
. The project aims to detect the position of the vehicle in the image using conventional methods such as HOG(Histogram of Oriented Gradient) and SVM(Support Vector Machine).
Udacity CarND provides datasets for vehicles and non-vehicles data to train classifier. It contains 8792
vehicle images and 8968
non-vehicle images. These datasets are comprised of images taken from the GTI vehicle image database, the KITTI vision benchmark suite, and examples extracted from the project video itself.
To train classifier, place images like:
# for vehicle dataset:
./classifier_images/vehicles/xxx/yyy.png (folder/file name dosen't matter)
# for non-vehicle dataset:
./classifier_images/non-vehicles/zzz/www.png
then follow Training_Classifier.ipynb
.
To generate video, follow Generate_Video.ipynb
.
You can find all the detail of vehicle detection pipeline on Vehicle_Detection_Pipeline.ipynb
.
The algorithm is structured as follows:
- Extracting Features from images
Spartially Binned Color
,Color Histogram
,HOG
skimage.feature.hog()
is used for extracting HOG features.
- Training Classifier
sklearn.svm.LinearSVC()
function is used.
- Searching Using Sliding Window and Classifying Each Window
find_car()
function is used for searching and classifying.
- Removing Multiple Detections and False Positives
apply_threshold()
function andscipy.ndimage.measurements.label()
function is used.
It took 6 minutes
to process 50 second
video and generate the output video using moviepy
. You can see full version of high resolution output video on Youtube: output_video
Input | Result |
---|---|
The accuracy of the classifier that distinguishes between vehicle and non-vehicle is about 98%. However, false possitives appear many times. I could reduce these false positives by using the previous frame's heatmap, but I could not remove them completely as shown in the image below. This false positive will be fatal when this detection algorithm is used for control the vehicle because The algorithm recognizes the empty road as obstacle.
This project used a classic method of detecting vehicles in images. but state-of-the-art vehicle detection methods are proposed these days. In the future, I will apply the following techniques to this video.