forked from sopdsfji/opensource_Teamproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_line.py
22 lines (16 loc) · 962 Bytes
/
draw_line.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def draw_lane_lines(original_image, warped_image, Minv, draw_info):
left_fitx = draw_info['left_fitx']
right_fitx = draw_info['right_fitx']
ploty = draw_info['ploty']
warp_zero = np.zeros_like(warped_image).astype(np.uint8)
color_warp = np.dstack((warp_zero, warp_zero, warp_zero))
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))
mean_x = np.mean((left_fitx, right_fitx), axis=0)
pts_mean = np.array([np.flipud(np.transpose(np.vstack([mean_x, ploty])))])
cv2.fillPoly(color_warp, np.int_([pts]), (216, 168, 74))
cv2.fillPoly(color_warp, np.int_([pts_mean]), (216, 168, 74))
newwarp = cv2.warpPerspective(color_warp, Minv, (original_image.shape[1], original_image.shape[0]))
result = cv2.addWeighted(original_image, 1, newwarp, 0.4, 0)
return pts_mean, result