Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Active-Lane-Keeping-Assistant/lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Lane:
"""
HLS_L_THRESHOLD_MIN = 150
HLS_L_THRESHOLD_MAX = 255
XM_PER_PIX = 3.7 / 781
def __init__(self, height:int, width:int, save:bool=False,
save_folder:str=join('img', 'examples')) -> None:
"""Constructor
Expand Down Expand Up @@ -463,7 +464,6 @@ def get_car_position(self, img:np.ndarray, left_line:np.ndarray,
[0]: Original image with lane and offset drawn on.
[1]: Calculated offset to the center of the detected lane.
"""
M_PER_PIX = 3.7 / 781 # Meters per pixel

# Retrieve the position of the car assuming it is the center of the
# image.
Expand All @@ -477,7 +477,7 @@ def get_car_position(self, img:np.ndarray, left_line:np.ndarray,

center_lane = (bottom_right - bottom_left)/2 + bottom_left
center_offset = (np.abs(car_location) - np.abs(center_lane)) * \
M_PER_PIX * 100
self.XM_PER_PIX * 100

cv2.putText(img, (f'Difference to Center: '
f'{str(round(center_offset, 5))} cm'), (int((5/600)*self.img_width),
Expand Down
Loading