Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def display_heading_line(frame, steering_angle, line_color=(0, 0, 255), line_width=5 ):
- heading_image = np.zeros_like(frame)
- height, width, _ = frame.shape
- # figure out the heading line from steering angle
- # heading line (x1,y1) is always center bottom of the screen
- # (x2, y2) requires a bit of trigonometry
- # Note: the steering angle of:
- # 0-89 degree: turn left
- # 90 degree: going straight
- # 91-180 degree: turn right
- steering_angle_radian = steering_angle / 180.0 * math.pi
- x1 = int(width / 2)
- y1 = height
- x2 = int(x1 - height / 2 / math.tan(steering_angle_radian))
- y2 = int(height / 2)
- cv2.line(heading_image, (x1, y1), (x2, y2), line_color, line_width)
- heading_image = cv2.addWeighted(frame, 0.8, heading_image, 1, 1)
- return heading_image
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement