/lane-detection

Lane and vehicle detection software for an autonomous vehicle.

Primary LanguageC++

lane-detection

Lane and vehicle detection software for an autonomous vehicle

This project is still under development and was built for educational purposes. An application was designed following the model-view-controller architecture to enable multiple autonomous vehicle algorithms to be simulated in different views and to allow the input parameters to be altered in run time e.g. adaptive threshold parameters, coordinates for inverse perspective mapping, number of sample points etc. The code will run slower due to the MVC architecture.

main.cpp is the view, laneDetectorController.hpp is the controller for the lane detection and vehicleDetectorController.hpp is the controller for the vehicle detection (both controllers are derived from the base Controller class in controller.hpp).

Lane Detection

Files/Classes

laneDetector.hpp acts as the model for the lane detection and contains the LaneDetector class.

The lane detection utilises the LineFinder class within lineFinder.hpp which is capable of finding and drawing lines using the Hough Transform and the Probabilistic Hough Transfrom.

IPM.hpp contains the IPM class for inverse perspective mapping, based on that seen in Marco Nieto's Blog (https://marcosnietoblog.wordpress.com/2014/02/22/source-code-inverse-perspective-mapping-c-opencv/). The IPM class is capable of converting the vehicle's front view to a birds eye view.

laneTracker.hpp contains the LaneTracker class which tracks and predicts the lane markers using a Kalman filter.

Algorithm

The lane detection algorithm utilises image enhancement techniques including temporal blurring and inverse perspective mapping before splitting the image into two halves for further processing. Instances of the LaneDetector class are then created for each image in order to detect the lane markers. An adaptive threshold is then used to detect the edges within each image. The LineFinder class is then used to detect lines using both the Hough Transform and Probabilistic Hough Transform. Any lines which do not resemble lane markers are removed (incorrect orientation etc). A bitwise AND operation of the two results is then used to combine the results for optimal line selection. The Hough Transform function within the LineFinder class is then used to detect the 10 most probable lines within the resulting image.

The image is then sampled along it’s height and linear least squares regression is used to calculate the best fit line for the lane marker. The lines rho (distance from the coordinate origin) and theta (the line rotation angle in radians) are then calculated.

Two instances of the LaneTracker class are then created in order to track the lane marker in each image. The line parameters (rho, theta) are used as inputs to the Kalman Filter. If no best fit line is detected then the Kalman Filter predicts the parameters.

Vehicle Detection

Files/Classes

vehicleDetector.cpp acts as the model for the vehicle detection and contains the VehicleDetector class.

Algorithm

The vehicle detection algorithm utilises a Haar Cascade which is trained using an MIT vehicle dataset. The input frame is converted to grayscale before undergoing histogram equalisation. Objects of different sizes are then detected using the Haar Cascade and stored in a list of rectangles. The detected cars are then marked on the output image.