Cars detection

Cars detection

Adrian Kollar

This project started with car detection using Haar Cascade Classifier. Then we focused on eliminating false positive results by using road detection. We tested the solution on a recorded video, which was obtained with a car camera recorder.

Functions used: cvtColor, canny, countNonZero, threshold, minMaxLoc, split, pow, sqrt, detectMultiScale

The Process

  1. Capture road sample every n-th frame, by capturing rectangle positioned statically in the frame (white rectangle in the examples). Road sample shouldn’t contain line markings. We used canny and countNonZero to avoid line marking.

    kollar_samples

    Road samples

  2. Calculate average road color from captured road samples

    kollar_avg_color

    Average road color

  3. Convert image and average road sample to LAB color space.
  4. For each pixel from the input image, calculate:kollar_equation

    where L, A, B are values from the input image and l, a, b are values from average road sample.

  5. Binarize the result by using threshold function.

Example

Kollar_car_detection

Input image, car detected is in red rectangle

kollar_detection

Road detection