From 27c3890d9e97b063ebadee9de6c77328c8ecbe9e Mon Sep 17 00:00:00 2001 From: wutong88yuyu <2179751939@qq.com> Date: Thu, 18 Dec 2025 18:25:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E7=B1=B3/=E5=83=8F=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Active-Lane-Keeping-Assistant/lane.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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),