Edge Recognition

Study note for recognizing road edge.

import matplotlib.image as mplimg

import matplotlib.pyplot as plt

import cv2  //opencv

img = mplimg.imread('road.jpg')

plt.imshow(img) //original image

img_gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)  //converted to gray scale image

img_grayb = cv2.GaussianBlur(img_gray, (7, 7), 0, 0) //blurred by gaussian filter, blur size =7

edges = cv2.Canny(img_grayb, 50, 100) //get the canny edges of the image. only points with gradient > 100 are shown

plt.imshow(edges)

//to connect the points

//use Hough Transformation

//it gets the distance to a point from different angles

//save all (angle, distance) pairs for all points in a grid

//the dense cells in the grid represents a common angle shared by many points

//which means the orthogonal line cross all those points.

//no codes, check wiki

//refer to 从零开始学习无人驾驶技术 --- 车道检测