Skip to content

DongzhenHuangfu/CarND-Vehicle-Detection

 
 

Repository files navigation

Vehicle Detection Project

Click the pictures to see the final result of the videos.

Result of challenge video


The goals / steps of this project are the following:

  • Perform a Histogram of Oriented Gradients (HOG) feature extraction on a labeled training set of images and train a classifier Linear SVM classifier
  • Normalize the features and randomize a selection for training and testing.
  • Apply a color transform and append binned color features, as well as histograms of color, to my HOG feature vector.
  • Implement a sliding-window technique and use my trained classifier to search for vehicles in images.
  • Run my pipeline on a video stream (start with the test_video.mp4 and later implement on full project_video.mp4) and create a heat map of recurring detections frame by frame to reject outliers and follow detected vehicles.
  • Estimate a bounding box for vehicles detected.

Rubric Points

Here I will consider the rubric points individually and describe how I addressed each point in my implementation.


You're reading it!

Histogram of Oriented Gradients (HOG)

1. How I extracted HOG features from the training images.

The code for this step is contained in the first part of the IPython notebook.

I started by reading in all the vehicle and non-vehicle images. Here is an example of one of each of the vehicle and non-vehicle classes:

I then explored different color spaces and different skimage.hog() parameters (orientations, pixels_per_cell, and cells_per_block). I grabbed random images from each of the two classes and displayed them to get a feel for what the skimage.hog() output looks like.

Here is an example using the YUV color space and HOG parameters of orientations=11, pixels_per_cell=(16, 16) and cells_per_block=(2, 2):

2. How I settled on my final choice of HOG parameters.

I tried various combinations of parameters and see how they look like, I also tried some different combinations of parameters to train the different classifiers with train data set and see how it looks like in the valid data set. Finally decided to choose this combination of the parameters.

3. How I trained a classifier using my selected HOG features and color features.

I trained a linear SVM using grid_search in sklearn, at first I tried to explore as many methods and parameters as possible, with a file called tune_svm.ipynb, but failed because of the huge cost of time. So I tried only LinearSVC and used the default parameters, the result is also good enough.

Sliding Window Search

1. How I implemented a sliding window search. How did I decide what scales to search and how much to overlap windows.

I decided to search in the area where y pixels are in the range of 400-560, cause the other part of the pictures are not possible to appear a car.

With lots of experiments I finally decided to use the scales of 1, 1.3, 1.5, 1.7 and 2, the moving step is 2. There is the picture demonstrating the area and windows I used for searching.

2. Result for pictures

Ultimately I searched on two scales using YUV 3-channel HOG features plus spatially binned color and histograms of color in the feature vector, which provided a nice result. I also used a add heat technique here to gather the multiple windows whiche overlape each others together and kicked out some of the false prediction. Here are some example images:


Video Implementation

1. Result of the video

Here's a link to my video result

2. HowI implemented some kind of filter for false positives and some method for combining overlapping bounding boxes.

I recorded the positions of positive detections in each frame of the video. From the positive detections I created a heatmap and then thresholded that map to identify vehicle positions. I then used scipy.ndimage.measurements.label() to identify individual blobs in the heatmap. I then assumed each blob corresponded to a vehicle. I constructed bounding boxes to cover the area of each blob detected.

To make it more smooth and robust, I used the same technology as my last project: Advanced Lane Lines, that is: take the average of the last n frames of heat. Further, I also kicked off all the 'strange windows'( dx * 1.3 < dy).

To make it more convenient for testing, I copied all the necessary code into file process_video.ipynb, and in there, I also add the technich from Advanced Lane Lines to show the lane line also.

Here's an example result showing the heatmap from a series of frames of video, the result of scipy.ndimage.measurements.label() and the bounding boxes then overlaid on the last frame of video:

Here are six frames and their corresponding heatmaps:

Here is the output of scipy.ndimage.measurements.label() on the integrated heatmap from all six frames:

Here the resulting bounding boxes are drawn onto the last frame in the series:


Discussion

The techniques I used:

  1. Hog, histogramm and spatial features for training and pediction.
  2. svm classifier, more preciously LinearSVC.
  3. Sliding window techniques for finding the car.
  4. Technique from the project Advanced Lane Lines to adding the lane line and relevant information on the video.

The problems I met:

  1. There are some frames that windows will appear at the wrong place, the solution may lay on tuning the shape of sliding windows, using other features or using other kind of classifiers.
  2. It is quiet weird that the total procesing time is very high(about 7.5 hours) when I used the two techniques(finding lane line and vehicle detection) together, cause each of them only need about 15 minutes when I use it alone.

About

Vehicle Detection Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 100.0%