diff --git a/src/Active-Lane-Keeping-Assistant/lane.py b/src/Active-Lane-Keeping-Assistant/lane.py index 50b5909827..9a7cd67f09 100644 --- a/src/Active-Lane-Keeping-Assistant/lane.py +++ b/src/Active-Lane-Keeping-Assistant/lane.py @@ -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 @@ -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. @@ -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),