Skip to content

Week3 : Edge filter

lasithaya edited this page Apr 1, 2020 · 4 revisions

Now let's filter out edges of the lane so we can detect the lane lines.

create a example5_edge_filter.py file and add the detect_edges function as follows.

def detect_edges(frame):
    # filter for blue lane lines
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    lower_blue = np.array([60, 40, 40])
    upper_blue = np.array([150, 255, 255])
    mask = cv2.inRange(hsv, lower_blue, upper_blue)
    

    # detect edges
    edges = cv2.Canny(mask, 200, 400)

    return edges

The code section edges = cv2.Canny(mask, 200, 400) detect the edges using the canny edge filter. More information can be found here Canny Edge Filter

Run the node and you will see a picture similar to the following.

Clone this wiki locally