Skip to content

Instantly share code, notes, and snippets.

@pknowledge
Created August 22, 2019 20:14
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save pknowledge/86a148c6cd5f0f2820ba81561cc00a8e to your computer and use it in GitHub Desktop.
Save pknowledge/86a148c6cd5f0f2820ba81561cc00a8e to your computer and use it in GitHub Desktop.
Road Lane Line Detection with OpenCV
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()
@tanzeel27
Copy link

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

@akshit7165
Copy link

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!

@nthuls
Copy link

nthuls commented Jul 6, 2023

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