We learned about region-of-interest masking in Chapter 4, Computer Vision for Self-Driving Cars. The next step toward identifying road markings is to mask the region of interest in our image:
- Import the required libraries:
In[1]: import cv2
In[2]: import numpy as np
In[3]: import matplotlib.pyplot as plt
- Next, write a function for canny edge detection:
In[4]: def canny_edge(image):
gray_conversion= cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
blur_conversion = cv2.GaussianBlur(gray_conversion, (5,5),0)
canny_conversion = cv2.Canny(blur_conversion, 50,150)
return canny_conversion
- Now, we will write a function for the region-of-interest masking. We will check the image manually to identify the inputs as polygons. We will plot the image and then verify the points mentioned in the polygons:
In[5]: def reg_of_interest(image):
Image_height = image.shape[0]
polygons = np.array([[(200, Image_height), (1100...