Lane detection plays a significant role in computer vision and autonomous driving applications. However, it encounters challenges under low-light conditions during nighttime, where images are darker and real-time processing is necessary. In this study, a nighttime lane detection method based on OpenCV is proposed. Initially, image contrast stretching is applied to enhance brightness as a preprocessing step. By adjusting the grayscale range of the image, lane line features can be captured more effectively. Median filtering and bilateral filtering are then employed to reduce noise interference in the image. To address potential left-right deviation caused by the camera, a novel dynamic Region of Interest (ROI) method is introduced. This method adaptively adjusts the ROI based on real-time image analysis, thereby reducing false detections and improving overall detection performance. Canny edge detection and Hough transform are utilized to locate the lane lines. Finally, lane fitting and drawing techniques are applied to determine the vehicle's position within the lane. Experimental results demonstrate the high accuracy and robustness of the proposed nighttime lane detection method, which incorporates enhanced images and the dynamic ROI approach. The method accurately identifies the vehicle's lane position, providing essential visual guidance for autonomous driving systems.