Created
August 22, 2019 20:14
-
-
Save pknowledge/86a148c6cd5f0f2820ba81561cc00a8e to your computer and use it in GitHub Desktop.
Road Lane Line Detection with OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pylab as plt | |
import cv2 | |
import numpy as np | |
image = cv2.imread('road.jpg') | |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | |
print(image.shape) | |
height = image.shape[0] | |
width = image.shape[1] | |
region_of_interest_vertices = [ | |
(0, height), | |
(width/2, height/2), | |
(width, height) | |
] | |
def region_of_interest(img, vertices): | |
mask = np.zeros_like(img) | |
channel_count = img.shape[2] | |
match_mask_color = (255,) * channel_count | |
cv2.fillPoly(mask, vertices, match_mask_color) | |
masked_image = cv2.bitwise_and(img, mask) | |
return masked_image | |
cropped_image = region_of_interest(image, | |
np.array([region_of_interest_vertices], np.int32),) | |
plt.imshow(cropped_image) | |
plt.show() |
I need the link to the exact image
Please help
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to install the matplotlip lib using the pip command onto your cmd, if you have pip the just write pip install matplotlib. After this you'll be good to go, cheers!