{"id":21603037,"url":"https://github.com/rbhatia46/lane-line-detection","last_synced_at":"2025-07-31T12:39:35.216Z","repository":{"id":112798659,"uuid":"163130583","full_name":"rbhatia46/Lane-Line-Detection","owner":"rbhatia46","description":"Using OpenCV to detect Lane Lines on a road, one of the most fundamental concepts for building a Self-Driving car.","archived":false,"fork":false,"pushed_at":"2018-12-26T03:55:45.000Z","size":29386,"stargazers_count":43,"open_issues_count":1,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T02:45:59.490Z","etag":null,"topics":["computer-vision","image-processing","lane-lines-detection","opencv","self-driving-cars"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rbhatia46.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-26T03:09:55.000Z","updated_at":"2025-03-19T03:35:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd8c0507-af07-47d4-b489-13e829691bc8","html_url":"https://github.com/rbhatia46/Lane-Line-Detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rbhatia46/Lane-Line-Detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FLane-Line-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FLane-Line-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FLane-Line-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FLane-Line-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbhatia46","download_url":"https://codeload.github.com/rbhatia46/Lane-Line-Detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbhatia46%2FLane-Line-Detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268040196,"owners_count":24185845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","image-processing","lane-lines-detection","opencv","self-driving-cars"],"created_at":"2024-11-24T19:14:57.420Z","updated_at":"2025-07-31T12:39:35.189Z","avatar_url":"https://github.com/rbhatia46.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Lane Line Detection\nDetecting Lane lines is one of the most fundamental concepts for building a Self Driving Car. In this repository, I have used OpenCV to detect lane lines in a sample video sample obtained from a camera places on a car.\n\nYou need OpenCV to run this project on your local machine and it can be installed simply by a single command - \u003cbr\u003e\n```pip install opencv-python```\n\n![Demo](https://i.ibb.co/1bQcV0Y/Working.gif)\n\n## How to run\n1. Download/Clone the repo.\n2. Make sure you have OpenCV installed for Python.(I recommend installing it on top of Anaconda Distribution)\n3. Execute the **lanes.py** script\n```\npython lanes.py\n```\n4. Make changes accordingly to use any other video file you might want to.(You can also use a static image, I have commented the image code since video is more useful.)\n\n## Intuition behind Concepts\n\nEvery image is essentially a numpy array at the end of the day, with values containing pixel intensities, 0 denoting complete black(dark) and 1 denoting complete white(bright), considering a grayscale image.\n\n### 1. Gaussian Blur\nUsed to reduce noise and smoothen out the image. We generally use a kernel of some specific size(say 5x5) and a deviation\n\n![Gradient](https://i.ibb.co/zNNtJYp/Gradient.png)\n\nThe above image shows a **Strong gradient** on the left and a **Weak Gradient** on the right.\n\nGradient : Change in brightness over a series of pixels.\n### 2. Canny Edge Detection\nAs the name suggests, it is an algorithm to detect edges in our image.\nA change in intensity of pixels will give us an edge.\n\nSmall change will imply small change in intensity whereas a Large derivative is a large change. \n\n```python\ncv2.Canny(image,low_threshold,high_threshhold)\n```\n\nIf a gradient is larger than the **high_threshold**, then it is accepted as an edge pixel. If it is below the **low_threshold**, it is rejected. Always use a ratio of 1:3 or 1:2.\n\n**NOTE : Line 34 in the code is optional and can be omitted, since the Canny function automaticallyapplies a Gaussian Blur with a kernel of 5x5.**\n\nExample : \n```python\ncv2.Canny(image,50,150)\n```\n\n### 3. Hough Transform\nAfter we have successfully detected edges in our image, it's time to detect lane lines in our image, for which we can use the Hough transform.\n\nBefore that, we need to find the **Region on interest** in our image. For that, we use Matplotlib to get a fair enough idea about the coordinate values of the image. \u003cbr\u003e\n\nOnce we are done, we create a mask with a polygon over it as shown :\n![Mask](https://i.ibb.co/DrLNSJR/Mask.png)\n\n0000 represents the black pixels and 11111111 represents the white pixels, denoting the polygon. Now, we apply the **bitwise_and** in the original image and the mask to obtain the **masked_image**, which essentially will contain only the region on interest.\n\n![Masked Image](https://i.ibb.co/LJFykXC/Masked-Image.png)  \n### Ultimate Result \u003cbr\u003e\n![Final Masked Image](https://i.ibb.co/711SBhW/Final-Masked-Image.png)\n\nFinally, now when we have only the Region of interest in our image, we will use Hough Transform to detect Straight lines in our image. \n\nEquation of a straight line can be given as :\n**y = mx + c**, where 'm' is the *slope* and 'c' is the *y-intercept*.\n\nWe can transform every line from 2D Space(X vs Y) to the Hough Space(M vs C).\nJust remember that - **A single point is 2D Space is represented by a line in Hough Space.**\n\n#### Ultimate Goal - Try to find a line that best describes our points.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbhatia46%2Flane-line-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbhatia46%2Flane-line-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbhatia46%2Flane-line-detection/lists"}