{"id":21095050,"url":"https://github.com/zoroxide/lane-detection","last_synced_at":"2026-04-28T09:06:22.113Z","repository":{"id":207918683,"uuid":"720419814","full_name":"zoroxide/Lane-Detection","owner":"zoroxide","description":"OpenCV Program Detects Lanes on the road","archived":false,"fork":false,"pushed_at":"2025-05-15T12:51:52.000Z","size":21144,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-01T03:43:48.901Z","etag":null,"topics":["ai","opencv","python"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/zoroxide.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}},"created_at":"2023-11-18T12:37:25.000Z","updated_at":"2025-05-15T12:51:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"0bdb1efb-e57f-48d8-9018-a3b4767b176b","html_url":"https://github.com/zoroxide/Lane-Detection","commit_stats":null,"previous_names":["zoroxide/lane-detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zoroxide/Lane-Detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoroxide%2FLane-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoroxide%2FLane-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoroxide%2FLane-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoroxide%2FLane-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoroxide","download_url":"https://codeload.github.com/zoroxide/Lane-Detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoroxide%2FLane-Detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32373558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"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":["ai","opencv","python"],"created_at":"2024-11-19T22:22:11.102Z","updated_at":"2026-04-28T09:06:22.064Z","avatar_url":"https://github.com/zoroxide.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1\u003ePython (openCV) Lane Detection\u003c/h1\u003e\n\u003cbr\u003e\n\n\n\n\nhttps://github.com/zoroxide/Lane-Detection/assets/72279810/0f275452-356c-46c8-b720-d7df72f4c81d\n\n\u003cbr\u003e\n\n![test3](https://github.com/zoroxide/Lane-Detection/assets/72279810/0c5bc9b5-5f86-4ac4-8bb1-338158b3cde6)\n\n\u003cbr\u003e\n\n\n![test4](https://github.com/zoroxide/Lane-Detection/assets/72279810/d47b5758-1b53-4f9c-bf93-de3149cb1d4e)\n\n\u003cbr\u003e\n\n# Code explanation \n\n\n```python\nimport cv2\nimport numpy as np\n```\n\nThese lines import the necessary libraries: `cv2` for computer vision operations and `numpy` for numerical operations.\n\n```python\ndef region_of_interest(img, vertices):\n    mask = np.zeros_like(img)\n    cv2.fillPoly(mask, vertices, 255)\n    masked_img = cv2.bitwise_and(img, mask)\n    return masked_img\n```\n\nThe `region_of_interest` function creates a mask for the region of interest in the image defined by the `vertices` parameter. It's used to focus on the area of the image where the lane lines are expected.\n\n```python\ndef draw_lines(img, lines, color=(0, 255, 0), thickness=3):\n    for line in lines:\n        for x1, y1, x2, y2 in line:\n            cv2.line(img, (x1, y1), (x2, y2), color, thickness)\n```\n\nThe `draw_lines` function draws lines on the image. It takes a list of lines (`lines`) and draws each line on the input image (`img`) using `cv2.line`.\n\n```python\ndef process_image(image):\n    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n    blur = cv2.GaussianBlur(gray, (5, 5), 0)\n    edges = cv2.Canny(blur, 50, 150)\n\n    height, width = edges.shape\n    vertices = np.array([[(0, height), (width / 2, height / 2), (width, height)]], dtype=np.int32)\n    roi = region_of_interest(edges, vertices)\n\n    lines = cv2.HoughLinesP(roi, 1, np.pi/180, threshold=50, minLineLength=100, maxLineGap=30)\n\n    if lines is not None:\n        line_image = np.zeros_like(image)\n        draw_lines(line_image, lines)\n        result = cv2.addWeighted(image, 0.8, line_image, 1, 0)\n    else:\n        result = image\n\n    return result\n```\n\nThe `process_image` function takes an input image and performs the following steps:\n- Convert the image to grayscale.\n- Apply Gaussian blur to the grayscale image to reduce noise.\n- Use the Canny edge detector to find edges in the image.\n- Define a region of interest (ROI) to focus on a specific area of the image where the lane lines are expected.\n- Use the Hough transform to detect lines in the ROI.\n- Draw the detected lines on a black image (`line_image`).\n- Combine the original image with the lines using `cv2.addWeighted`.\n\n```python\ncap = cv2.VideoCapture('path_to_your_video.mp4')\n\nwhile cap.isOpened():\n    ret, frame = cap.read()\n    if not ret:\n        break\n\n    processed_frame = process_image(frame)\n\n    cv2.imshow('Lane Detection', processed_frame)\n\n    if cv2.waitKey(1) \u0026 0xFF == ord('q'):\n        break\n\ncap.release()\ncv2.destroyAllWindows()\n```\n\nThe main part of the code captures frames from a video file, processes each frame using the `process_image` function, and displays the result in a window. The loop continues until the 'q' key is pressed. Make sure to replace 'video.mp4' with the actual path to your video file, I have left one for testing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoroxide%2Flane-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoroxide%2Flane-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoroxide%2Flane-detection/lists"}