OpenCV
中的cv2.findContours()
函数。您可以在OpenCV文档中找到示例。_, contours, _ = cv2.findContours(your_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours
将拥有一系列轮廓。在您的情况下,每条车道将被添加为单独的轮廓。masks = []
for contour in contours:
img = np.zeros( (height, width) )
cv2.fillPoly(img, pts =[contours], color=(255,255,255))
masks.append(img)
而且您还可以使用 cv2.drawContours
函数,设置 thickness=cv2.FILLED
来创建掩模。
修改
首先确保所有黑色区域的 rgb
值都为 (0, 0, 0)
。 然后,您可以尝试在此处使用第二个参数中的值,并在findContours()
函数的第三个参数中使用此处中的值。
contour
列表,而 contour
是坐标列表。也许你可以尝试通过 contour
的坐标值来将它们分离。我没有想到任何其他方法。 - Ramesh-X
image = cv2.bitwise_and(image,image,mask=mask_lanes)
。看看它是否给出了车道线。 - zindarod