/self_driving_rc_car

Self Driving RC Car

Primary LanguagePython

Self Driving Car

Arduino Code -> main.cpp

Lane Detection -> lanes.py

Running Pi and ai -> pi_driver.py

1. Opencv

1.1 Gray

Since processing a 3-channel image will take a long time, we reduce the image to 1 channel.

The function we will use for this is:

gray = cv2.cvtColor(lane_image, cv2.COLOR_RGB2GRAY)

rgb_to_gray

1.2 GaussianBlur

Gaussian blur is used as a preprocessing step in many cases like canny edge detection.

Gaussian blur the image to reduce the amount of noise and remove speckles within the image. It is important to remove the very high frequency components that exceed those associated with the gradient filter used, otherwise, these can cause false edges to be detected.

blur = cv2.GaussianBlur(gray, (5,5), 0)

gif

1.3 Canny

candy candy Output: candy

canny = cv2.Canny(blur, 50, 150)

1.4 Region of Interest

def region_of_interest(image):
    height = image.shape[0]
    triangle = np.array([
        [(200, height), (1100, height), (550, 250)]
        ])
    mask = np.zeros_like(image)
    cv2.fillPoly(mask, triangle, 255)
    return mask

roi

Output: roi