Detect vehicles in a video feed.
The goals / steps of this project are the following:
single_img_features
function in helper_fuctions.py
provides the code for the feature extraction.
I started by exploring 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 are the output images with HOG parameters of ‘orient = 9’, ‘pix_per_cell = 8’, ‘cell_per_block = 2’, ‘hog_channel = 1’, ‘spatial_size = (4, 4)’, ‘hist_bins = 32’:
‘HSL’ Colorspace: ‘HSV’ Colorspace: ‘RGB’ Colorspace: ‘YCrCb’ Colorspace: ‘YUV’ Colorspace:
I tried various combinations of parameters and tried plotting histogram features for many random images for both car and non-car caterogy. Finally, the chosen parameters gave distinctictive results and better accuracy than other.
For colorspace, YCrCb
and YUV
were giving good results. So, I proceeded with YUV
at first.
I started with extracting 3000
random car & noncar images for spatial
, color
and hog
features. Then, I normalized the features and splitted them to train and test features with ratio of 0.9:0.1
. Then, I trained it with LinearSVC
.
I decided to search the image for vehicle in Y range of [400, 720]
and complete X range
, because all of the vehicles appear in that region. Upper region in Y axis is filled with trees/skies. I started with window size of 64 for selected region.
I tried to reduce false positives by adding heat threshold of 5.
Using parameters, scale = 1, heat_threshold = 5, window = 64, samples=8500, colorspace='YUV'
. I got following image detection output:
As it was getting few false positives, I tried changing colorspace to 'YCrCb'
. It had no false positives in test image detection. The output is:
Upon modifying parameters to:
ystart = 400,
ystops = [486, 502, 534, 646, 646],
scales = [0.72, 1, 1.5, 2, 2.5],
heat_threshold = 3,
window = 64
.
I get following output:
I used multiple windows to get more accurate detection as possible & added the threshold of 3 to remove the false detection.
scales = [0.72, 1, 1.5, 2, 2.5],
heat_threshold = 3
Here’s a link to test video result & link to project video result
I used the method as in image detection to filter the false positives with combining overlapping bounding windows in single frame with threshold of 6.
Getting detected one particular vehicle in image was a big problem. Here, the image with that vehicle:
When I tried to increase the threshold for heatmap, this vehicle was not getting detected. On decreasing the threshold the other image were getting 1-2 false positives.
So, I tested various scales
& xstops
for optimal detection. Finally, I was able to detect that particular vechicle.