Self-driving vehicles require the ability to perceive and understand their surroundings, just like human drivers. It entails navigating efficiently on roads, obeying traffic signs and signals, and avoiding collisions with other vehicles and pedestrians. To address the challenges associated with object detection in self-driving cars, an effort was made to demonstrate lane detection using the OpenCV library. To achieve this goal, the well-established probabilistic Hough transform technique is used for line detection. Before applying Hough transforms, several pre-processing techniques are used, including converting the image to grayscale, camera calibration, and implementing a masking filter. In addition, edge detection is performed using the edge detection method. The study also indicates a preference for the use of HSL (Hue, Saturation, and Lightness) and HSV (Hue, Saturation, Value) color spaces. When HSL is applied, white lines appear purer and brighter, resulting in superior performance compared to using HSV specifically to detect white. This algorithm proved particularly effective in detecting straight lanes, which achieved an accuracy ratio of 96.06%. By incorporating these methodologies, the lane detection algorithm implemented with the OpenCV library addresses the challenges of self-driving vehicles, providing them with improved perception capabilities similar to human drivers.