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
- 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.
- Calculate average road color from captured road samples
- Convert image and average road sample to LAB color space.
- For each pixel from the input image, calculate:
where L, A, B are values from the input image and l, a, b are values from average road sample.
- Binarize the result by using threshold function.