In [ ]:
# def extend_lines(lines):
#     right = []
#     left = []
#     for x1,y1,x2,y2 in lines[:, 0]:
#         m = (float(y2) - y1) / (x2 - x1)
#         if m >= 0: 
#             right.append([x1,y1,x2,y2, m])
#         else:
#             left.append([x1,y1,x2,y2, m])
#     right = reject_outliers(right, cutoff=(0.45, 0.75)) #, 
#     right = np.array(right)[:, :4]
    
#     left = reject_outliers(left, cutoff=(-0.85, -0.6)) #, 
#     left = np.array(left)[:, :4]

#     ### Generate Right Lane
#     x1,y1,x2,y2 = np.mean(right, axis=0)
#     x1e, y1e = extend_point(x1,y1,x2,y2, -1000) # right bottom
#     x2e, y2e = extend_point(x1,y1,x2,y2, 1000)  # right top
#     right_lane = np.array([[x1e,y1e,x2e,y2e]])
# #     right_lane = merge_prev(right_lane, right_prev)
    
#     ### Generate Left Lane
#     x1,y1,x2,y2 = np.mean(left, axis=0)
#     x1e, y1e = extend_point(x1,y1,x2,y2, -1000) # left bottom
#     x2e, y2e = extend_point(x1,y1,x2,y2, 1000)  # left tip
#     left_lane = np.array([[x1e,y1e,x2e,y2e]])
# #     left_lane = merge_prev(left_lane, left_prev)


#     return np.array([right_lane, left_lane], dtype=np.int32)

# def find_intersection(lines):
#     """ Finishing touch to adjust the apex on the horizon with the lane line intersection """
#     R, L = lines[0][0], lines[1][0]
#     Rx, Ry = [R[0], R[2]], [R[1], R[3]]
#     Lx, Ly = [L[0], L[2]], [L[1], L[3]]
    
#     # Get coefficients for lines
#     Rc = np.polyfit(Rx, Ry, 1)
#     Lc = np.polyfit(Lx, Ly, 1)
    
#     # Calculate intersection
#     x = (Lc[1] - Rc[1]) / (Rc[0] - Lc[0])
#     y = (Rc[0]*x) + Rc[1] + 10
#     return [x,y]