In this project, computer vision techniques are used to accurately detect vehicles in a video and track them.
The video processing pipeline process_vid()
, consists of the following steps:
- Receiving input frame as an RGB image
- Extract features from the image, scaled in 4 different sizes: in 64x64 windows that are predicted to be cars, using
detect_vehicle()
function. - Generate a heatmap using the predicted windows using the
generate_heatmap()
function, using only pixels that are higher than the specifiedthreshhold
. - Use the
label()
function from the library SciPy'sscipy.ndimage.measurements
module, to group each group of overlapping windows into single windows. - Assume each labeled window is a possible vehicle, and calculate it's dimensions (centers, width, height), and add to
local_detections
as an object of the classVehicle()
. - Loop over the previously detected windows, and the currently detected and if both have close centers, assume that this detection resembles a new car: append this
Vehicle()
to the global arraycars
. - Loop over the detected
cars
, for everycar
, loop over thelocal_detections
:- If the centers and dimensions of the car and detection are close enough, do not save this detection for the next frame and assume its a car;
car.detected = True
. - Count how many times has this car been detected
car.n_detected += 1
andcar.not_detected -= 1
. - If the car wasn't similar to any of the detected windows, increment
car.not_detected += 1
.
- If the centers and dimensions of the car and detection are close enough, do not save this detection for the next frame and assume its a car;
- Using the number of frames the car has been detected or not, we can approach a decision: * Either: Draw the window detected since it most probably resembles a car. * Or: Remove the detected window since it was presumably a false positive.
- The average of widths and heights are used to smooth the window drawn to make sure there aren't any abrupt changes in window's dimensions.
Check this video to preview the pipeline's output
Here is a youtube link for my video to stream it online.
Please check the writeup report for further details *Also check my implementation contained in this IPython Notebook