Advertisement
Guest User

Untitled

a guest
May 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. def display_heading_line(frame, steering_angle, line_color=(0, 0, 255), line_width=5 ):
  2. heading_image = np.zeros_like(frame)
  3. height, width, _ = frame.shape
  4.  
  5. # figure out the heading line from steering angle
  6. # heading line (x1,y1) is always center bottom of the screen
  7. # (x2, y2) requires a bit of trigonometry
  8.  
  9. # Note: the steering angle of:
  10. # 0-89 degree: turn left
  11. # 90 degree: going straight
  12. # 91-180 degree: turn right
  13. steering_angle_radian = steering_angle / 180.0 * math.pi
  14. x1 = int(width / 2)
  15. y1 = height
  16. x2 = int(x1 - height / 2 / math.tan(steering_angle_radian))
  17. y2 = int(height / 2)
  18.  
  19. cv2.line(heading_image, (x1, y1), (x2, y2), line_color, line_width)
  20. heading_image = cv2.addWeighted(frame, 0.8, heading_image, 1, 1)
  21.  
  22. return heading_image
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement