This repository implements the vision pipeline for lane detection used in UTRA's autonomous rover team (ART).
- Python (any version)
- OpenCV 3.0.0 or higher
All the code is contained within main.py
. Running it will process the images in input_images/
and return the images with the detected lanes annotated onto them, found in test/
.
To ensure OpenCV is installed
- Run
import cv2
in python3 - It should return with no errors
Run main.py as
python3 main.py
on the bash terminal to execute line detection
- Install the
teb_local_planner
ROS package for ROS Kinetic - Terminal 1:
roslaunch teb_local_planner test_optim_node.launch
- Source your ws:
cd catkin_ws && source devel/setup.bash
- Terminal 2:
rosrun teb_obstacles main.py
(Optional: to run Husky simulation in the rviz window) - Terminal 3:
roslaunch husky_gazebo husky_empty_world.launch
- Terminal 4:
roslaunch husky_teleop teleop.launch
The lane detection is comprised of two parts:
We first process input image in order to produce a binary image that only contains white lines, signifying the la on a black background. This is done by applying two different thresholding methods, on the Saturation Channel and Sobel thresholding, to two copies of the input image, respectively. The resulting binaries are combined to produce the resulting thresholded image, followed by a median blur to smooth out remaining white speckles. Finally, the binary image is transformed from perspective to bird's eye view before being passed to the lane detection module. See Results to see the generated binary.
Lanes are detecting by performing a sliding-window based algorithm to the binary output from the preprocessing stage. First, a histogram is generates along a given axis based on the number of whtie pixels along each column. The histogram is then partitioned into bins along the axis, and bins whose histogram values exceed a heuristically determined cutoff are saved. For each of these bins, the coordinates of the pixels are obtained, and are passed into np.plyfit
. Bucket sizes must be large enough to encompass highly curved images, but small enough so as not not overlap with a potentially neighbouring line.
1280x720 JPEG input from stereo camera:
Then using a sliding-window algorithm which polyfits in horizontal and vertical directions: