Road Detection - olinrobotics/gravl GitHub Wiki

The format of this will discuss a filter, with the least flattering image followed by the most flattering image. In scripts/recognize_road, there is a class method called recognize_road which is used to filter the images taken from the /camera/image_raw topic.

To test this, run a rosbag or connect to the pointgrey directly and run rosrun tractor recognize_road.

Gabor Filter

This gabor filter combines features oriented between -45 and 45 degrees.

    def recognize_road(self, img):
        img = img[300:964, :]  # Cut out the sky
        filters = []
        for theta in np.arange(np.pi/4,3 * np.pi/4, np.pi / 16):
            kern = cv2.getGaborKernel(
                (31, 31), 4, theta, 10.0, 0.1, 0.1, ktype=cv2.CV_32F)
            kern /= 1.5 * kern.sum()
            filters.append(kern)
        accum = np.zeros_like(img)
        for kern in filters:
            fimg = cv2.filter2D(img, cv2.CV_8UC3, kern)
            np.maximum(accum, fimg, accum)

        return blurred

Here is the best case (location 7):

Here is the worst case (location 5):

Gaussian Blur

This was to be used as an enhancement over the gabor filter. I tried to using gaussian blur to squash noisy edges, but the edges that we want for the road do not exist in the first place. So not only did the gaussian blur visually make no impact, it made no meaningful progress as far as canny edge is concerned.

Equhist

I also tried using equhist as an enhancement for the gabor filter, which enhances contrast. Though it made the picture more contrasted and pleasant for us to see, it made no difference as far as other filters were concerned.