Skip to content

Commit

Permalink
Added method to draw a line on camera frame. (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
mageofboy authored May 23, 2022
1 parent 4bbe80e commit 54eda46
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pylot/perception/camera_frame.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Tuple, Union
from typing import List, Tuple, Union

import PIL.Image as Image

Expand Down Expand Up @@ -125,6 +125,20 @@ def draw_text(self,
thickness=1,
lineType=cv2.LINE_AA)

def draw_line(self, points: List[Vector2D], color, thickness: float = 3):
"""Draws lines between given points on the frame.
Args:
points: List of points of where to draw lines between.
color: RGB tuple for the color of he line.
"""
draw_points = np.array([[point.x, point.y] for point in points])
cv2.polylines(self.frame,
np.array([draw_points], dtype=np.int32),
False,
color,
thickness=thickness)

def in_frame(self, point: Vector2D) -> bool:
"""Checks if a point is within the frame."""
return (0 <= point.x <= self.camera_setup.width
Expand Down

0 comments on commit 54eda46

Please sign in to comment.