我是初学者,我正在尝试在游戏中进行一些线路检测。 这是我试图检测车道的照片 这是结果 HoughLinesP 代码:```lines = cv2.HoughLinesP(cropped_image, 2, np.pi / 180, 100, np.array([]), minLineLength=50,maxLineGap=5)
# The displaying function:
def displayLines(image, lines):
line_image = np.zeros_like(image)
if lines is not None:
for line in lines:
x1, x2, y1, y2 = line.reshape(4)
cv2.line(line_image, (x1, x2), (x2, y2), (0,255,0), 10)
return line_image```
# Here is the cropping function:
def region(image):
height = image.shape[0]
polygons = np.array([[
(570, 640), (1600, 700), (863, 520)
]])
mask = np.zeros_like(image)
cv2.fillPoly(mask, polygons, 255)
masked_image = cv2.bitwise_and(canny, mask)
return masked_image
#As input I'm giving image with edges displayed. Function:
def canny(image):
gray = cv2.cvtColor(lane_image, cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(gray, (5,5),0)
canny = cv2.Canny(blur, 50, 150)
return canny
我不知道是什么问题