I try to mark the road in the following figure, the yellow middle lines and the white edge lines.:
I use the standard code of Hough Transfrom. My code is as following:
import cv2
import numpy as np
img = cv2.imread('Road3.jpg')
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
low_yellow=np.array([18, 94, 140])
up_yellow=np.array([48, 255, 255])
mask=cv2.inRange(hsv, low_yellow, up_yellow)
edges = cv2.Canny(mask,75,150)
lines = cv2.HoughLinesP(edges,1,np.pi/180,50,maxLineGap=250)
for line in lines:
x1,y1,x2,y2 = line[0]
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),5)
cv2.imshow('image', img)
cv2.imshow("edges", edges)
k = cv2.waitKey(0)
cv2.destroyAllWindows()
But there is mistake feedback:
After changing the line with
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
It seems this is just part of the picture but I do not know where is the problem.
Based on Ahmet's answer, I can get the black one picture as follows but the color one is part of the whole picture.





