parameters: (img_undistorted, Minv, line_lt, line_rt, keep_state)
return_statement: return blend_onto_road
docstring: Draw both the drivable lane area and the detected lane-lines onto the original (undistorted) frame.
      :param img_undistorted: original undistorted color frame
      :param Minv: (inverse) perspective transform matrix used to re-project on original frame
      :param line_lt: left lane-line previously detected
      :param line_rt: right lane-line previously detected
      :param keep_state: if True, line state is maintained
      :return: color blend
docstring_summary: Draw both the drivable lane area and the detected lane-lines onto the original (undistorted) frame.
      :param img_undistorted: original undistorted color frame
      :param Minv: (inverse) perspective transform matrix used to re-project on original frame
      :param line_lt: left lane-line previously detected
      :param line_rt: right lane-line previously detected
      :param keep_state: if True, line state is maintained
      :return: color blend
docstring_tokens: Draw both the drivable lane area and the detected lane - lines onto the original ( undistorted ) frame . : param img_undistorted : original undistorted color frame : param Minv : ( inverse ) perspective transform matrix used to re - project on original frame : param line_lt : left lane - line previously detected : param line_rt : right lane - line previously detected : param keep_state : if True line state is maintained : return : color blend
function: def draw_back_onto_the_road(img_undistorted, Minv, line_lt, line_rt, keep_state):
      """
      Draw both the drivable lane area and the detected lane-lines onto the original (undistorted) frame.
      :param img_undistorted: original undistorted color frame
      :param Minv: (inverse) perspective transform matrix used to re-project on original frame
      :param line_lt: left lane-line previously detected
      :param line_rt: right lane-line previously detected
      :param keep_state: if True, line state is maintained
      :return: color blend
      """
      height, width, _ = img_undistorted.shape
  
      left_fit = line_lt.average_fit if keep_state else line_lt.last_fit_pixel
      right_fit = line_rt.average_fit if keep_state else line_rt.last_fit_pixel
  
      # Generate x and y values for plotting
      ploty = np.linspace(0, height - 1, height)
      left_fitx = left_fit[0] * ploty ** 2 + left_fit[1] * ploty + left_fit[2]
      right_fitx = right_fit[0] * ploty ** 2 + right_fit[1] * ploty + right_fit[2]
  
      # draw road as green polygon on original frame
      road_warp = np.zeros_like(img_undistorted, dtype=np.uint8)
      pts_left = np.array([np.transpose(np.vstack([left_fitx, ploty]))])
      pts_right = np.array([np.flipud(np.transpose(np.vstack([right_fitx, ploty])))])
      pts = np.hstack((pts_left, pts_right))
      cv2.fillPoly(road_warp, np.int_([pts]), (0, 255, 0))
      road_dewarped = cv2.warpPerspective(road_warp, Minv, (width, height))  # Warp back to original image space
  
      blend_onto_road = cv2.addWeighted(img_undistorted, 1., road_dewarped, 0.3, 0)
  
      # now separately draw solid lines to highlight them
      line_warp = np.zeros_like(img_undistorted)
      line_warp = line_lt.draw(line_warp, color=(255, 0, 0), average=keep_state)
      line_warp = line_rt.draw(line_warp, color=(0, 0, 255), average=keep_state)
      line_dewarped = cv2.warpPerspective(line_warp, Minv, (width, height))
  
      lines_mask = blend_onto_road.copy()
      idx = np.any([line_dewarped != 0][0], axis=2)
      lines_mask[idx] = line_dewarped[idx]
  
      blend_onto_road = cv2.addWeighted(src1=lines_mask, alpha=0.8, src2=blend_onto_road, beta=0.5, gamma=0.)
  
      return blend_onto_road
function_tokens: def draw_back_onto_the_road ( img_undistorted , Minv , line_lt , line_rt , keep_state ) : height , width , _ = img_undistorted . shape left_fit = line_lt . average_fit if keep_state else line_lt . last_fit_pixel right_fit = line_rt . average_fit if keep_state else line_rt . last_fit_pixel # Generate x and y values for plotting ploty = np . linspace ( 0 , height - 1 , height ) left_fitx = left_fit [ 0 ] * ploty ** 2 + left_fit [ 1 ] * ploty + left_fit [ 2 ] right_fitx = right_fit [ 0 ] * ploty ** 2 + right_fit [ 1 ] * ploty + right_fit [ 2 ] # draw road as green polygon on original frame road_warp = np . zeros_like ( img_undistorted , dtype = np . uint8 ) pts_left = np . array ( [ np . transpose ( np . vstack ( [ left_fitx , ploty ] ) ) ] ) pts_right = np . array ( [ np . flipud ( np . transpose ( np . vstack ( [ right_fitx , ploty ] ) ) ) ] ) pts = np . hstack ( ( pts_left , pts_right ) ) cv2 . fillPoly ( road_warp , np . int_ ( [ pts ] ) , ( 0 , 255 , 0 ) ) road_dewarped = cv2 . warpPerspective ( road_warp , Minv , ( width , height ) ) # Warp back to original image space blend_onto_road = cv2 . addWeighted ( img_undistorted , 1. , road_dewarped , 0.3 , 0 ) # now separately draw solid lines to highlight them line_warp = np . zeros_like ( img_undistorted ) line_warp = line_lt . draw ( line_warp , color = ( 255 , 0 , 0 ) , average = keep_state ) line_warp = line_rt . draw ( line_warp , color = ( 0 , 0 , 255 ) , average = keep_state ) line_dewarped = cv2 . warpPerspective ( line_warp , Minv , ( width , height ) ) lines_mask = blend_onto_road . copy ( ) idx = np . any ( [ line_dewarped != 0 ] [ 0 ] , axis = 2 ) lines_mask [ idx ] = line_dewarped [ idx ] blend_onto_road = cv2 . addWeighted ( src1 = lines_mask , alpha = 0.8 , src2 = blend_onto_road , beta = 0.5 , gamma = 0. ) return blend_onto_road