lane/line.py
def illustrate_driving_lane(
    img, left_line, right_line, lane_color=(255, 0, 255), road_color=(0, 255, 0)
):
    """
    #---------------------
    # This function draws lane lines and drivable area on the road
    #
    """

    # Create an empty image to draw on
    window_img = np.zeros_like(img)

    window_margin = left_line.window_margin
    left_plotx, right_plotx = left_line.allx, right_line.allx
    ploty = left_line.ally

    # Generate a polygon to illustrate the search window area
    # And recast the x and y points into usable format for cv2.fillPoly()
    left_line_window1 = np.array(
        [np.transpose(np.vstack([left_plotx - window_margin / 5, ploty]))]
    )
    left_line_window2 = np.array(
        [np.flipud(np.transpose(np.vstack([left_plotx + window_margin / 5, ploty])))]
    )
    left_line_pts = np.hstack((left_line_window1, left_line_window2))
    right_line_window1 = np.array(
        [np.transpose(np.vstack([right_plotx - window_margin / 5, ploty]))]
    )
    right_line_window2 = np.array(
        [np.flipud(np.transpose(np.vstack([right_plotx + window_margin / 5, ploty])))]
    )
    right_line_pts = np.hstack((right_line_window1, right_line_window2))

    # Draw the lane onto the warped blank image
    cv2.fillPoly(window_img, np.int_([left_line_pts]), lane_color)
    cv2.fillPoly(window_img, np.int_([right_line_pts]), lane_color)

    # Recast the x and y points into usable format for cv2.fillPoly()
    pts_left = np.array(
        [np.transpose(np.vstack([left_plotx + window_margin / 5, ploty]))]
    )
    pts_right = np.array(
        [np.flipud(np.transpose(np.vstack([right_plotx - window_margin / 5, ploty])))]
    )
    pts = np.hstack((pts_left, pts_right))

    # Draw the lane onto the warped blank image
    cv2.fillPoly(window_img, np.int_([pts]), road_color)
    result = cv2.addWeighted(img, 1, window_img, 0.3, 0)

    return result, window_img

    #---------------------
    # This function draws lane lines and drivable area on the road
    #
    
This function draws lane lines and drivable area on the road
This function draws lane lines and drivable area on the road
def illustrate_driving_lane(
    img, left_line, right_line, lane_color=(255, 0, 255), road_color=(0, 255, 0)
):
    window_img = np.zeros_like(img)
    window_margin = left_line.window_margin
    left_plotx, right_plotx = left_line.allx, right_line.allx
    ploty = left_line.ally
    left_line_window1 = np.array(
        [np.transpose(np.vstack([left_plotx - window_margin / 5, ploty]))]
    )
    left_line_window2 = np.array(
        [np.flipud(np.transpose(np.vstack([left_plotx + window_margin / 5, ploty])))]
    )
    left_line_pts = np.hstack((left_line_window1, left_line_window2))
    right_line_window1 = np.array(
        [np.transpose(np.vstack([right_plotx - window_margin / 5, ploty]))]
    )
    right_line_window2 = np.array(
        [np.flipud(np.transpose(np.vstack([right_plotx + window_margin / 5, ploty])))]
    )
    right_line_pts = np.hstack((right_line_window1, right_line_window2))
    cv2.fillPoly(window_img, np.int_([left_line_pts]), lane_color)
    cv2.fillPoly(window_img, np.int_([right_line_pts]), lane_color)
    pts_left = np.array(
        [np.transpose(np.vstack([left_plotx + window_margin / 5, ploty]))]
    )
    pts_right = np.array(
        [np.flipud(np.transpose(np.vstack([right_plotx - window_margin / 5, ploty])))]
    )
    pts = np.hstack((pts_left, pts_right))
    cv2.fillPoly(window_img, np.int_([pts]), road_color)
    result = cv2.addWeighted(img, 1, window_img, 0.3, 0)
    return result, window_img
def illustrate_driving_lane ( img , left_line , right_line , lane_color = ( 255 , 0 , 255 ) , road_color = ( 0 , 255 , 0 ) ) : window_img = np . zeros_like ( img ) window_margin = left_line . window_margin left_plotx , right_plotx = left_line . allx , right_line . allx ploty = left_line . ally left_line_window1 = np . array ( [ np . transpose ( np . vstack ( [ left_plotx - window_margin / 5 , ploty ] ) ) ] ) left_line_window2 = np . array ( [ np . flipud ( np . transpose ( np . vstack ( [ left_plotx + window_margin / 5 , ploty ] ) ) ) ] ) left_line_pts = np . hstack ( ( left_line_window1 , left_line_window2 ) ) right_line_window1 = np . array ( [ np . transpose ( np . vstack ( [ right_plotx - window_margin / 5 , ploty ] ) ) ] ) right_line_window2 = np . array ( [ np . flipud ( np . transpose ( np . vstack ( [ right_plotx + window_margin / 5 , ploty ] ) ) ) ] ) right_line_pts = np . hstack ( ( right_line_window1 , right_line_window2 ) ) cv2 . fillPoly ( window_img , np . int_ ( [ left_line_pts ] ) , lane_color ) cv2 . fillPoly ( window_img , np . int_ ( [ right_line_pts ] ) , lane_color ) pts_left = np . array ( [ np . transpose ( np . vstack ( [ left_plotx + window_margin / 5 , ploty ] ) ) ] ) pts_right = np . array ( [ np . flipud ( np . transpose ( np . vstack ( [ right_plotx - window_margin / 5 , ploty ] ) ) ) ] ) pts = np . hstack ( ( pts_left , pts_right ) ) cv2 . fillPoly ( window_img , np . int_ ( [ pts ] ) , road_color ) result = cv2 . addWeighted ( img , 1 , window_img , 0.3 , 0 ) return result , window_img
This function draws lane lines and drivable area on the road
This function draws lane lines and drivable area on the road
"""
    #---------------------
    # This function draws lane lines and drivable area on the road
    #
    """ # Create an empty image to draw on # Generate a polygon to illustrate the search window area # And recast the x and y points into usable format for cv2.fillPoly() # Draw the lane onto the warped blank image # Recast the x and y points into usable format for cv2.fillPoly() # Draw the lane onto the warped blank image
img
left_line
right_line
lane_color
road_color