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() |
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!
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
Traceback (most recent call last):
File "C:/Users/Agent/PycharmProjects/pythonProject1/main.py", line 1, in
import matplotlib.pylab as plt
File "C:\Users\Agent\PycharmProjects\pythonProject1\venv\lib\site-packages\matplotlib_init_.py", line 107, in
from . import _api, cbook, docstring, rcsetup
File "C:\Users\Agent\PycharmProjects\pythonProject1\venv\lib\site-packages\matplotlib\rcsetup.py", line 26, in
from matplotlib.colors import Colormap, is_color_like
File "C:\Users\Agent\PycharmProjects\pythonProject1\venv\lib\site-packages\matplotlib\colors.py", line 82, in
from matplotlib import _api, cbook, scale
File "C:\Users\Agent\PycharmProjects\pythonProject1\venv\lib\site-packages\matplotlib\scale.py", line 18, in
from matplotlib.ticker import (
File "C:\Users\Agent\PycharmProjects\pythonProject1\venv\lib\site-packages\matplotlib\ticker.py", line 179, in
from matplotlib import transforms as mtransforms
File "C:\Users\Agent\PycharmProjects\pythonProject1\venv\lib\site-packages\matplotlib\transforms.py", line 46, in
from matplotlib._path import (
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1
i am having these errors please guide