Skip to content

Fix(Finding_Lanes): Dynamic ROI, slope filtering, multi-source CLI, visualizer, unit tests & docs (#467) - #468

Open
Prayas340 wants to merge 2 commits into
ndleah:mainfrom
Prayas340:fix/finding-lanes-path-and-crashes
Open

Fix(Finding_Lanes): Dynamic ROI, slope filtering, multi-source CLI, visualizer, unit tests & docs (#467)#468
Prayas340 wants to merge 2 commits into
ndleah:mainfrom
Prayas340:fix/finding-lanes-path-and-crashes

Conversation

@Prayas340

@Prayas340 Prayas340 commented Aug 11, 2026

Copy link
Copy Markdown

Description

Fixes #467

This PR resolves multiple critical bugs, edge cases, and architectural limitations in Finding_Lanes:

  1. Dynamic ROI Polygon Masking: Replaced static pixel coordinates with dynamically scaled polygon vertices proportional to frame width and height, preventing distortion and out-of-bounds errors on arbitrary video and image resolutions.
  2. Color Space Standardization: Fixed Canny edge preprocessing to correctly convert OpenCV BGR frames via cv2.COLOR_BGR2GRAY.
  3. Slope-Intercept Noise Filtering & Coordinate Safety: Added min_slope filtering (default 0.3) in average_lines_intercept to ignore near-horizontal road markings and shadows. Added zero-division, NaN, and infinity safeguards in make_coordinate to prevent crashes and int conversion overflow.
  4. Multi-Source CLI Engine: Added CLI argument parsing (--image, --video, --camera, --output, --no-show) to process static images, pre-recorded video files, or live webcam streams, with optional output saving for headless / CI workflows.
  5. Multi-Stage Pipeline Visualizer (sub.py): Enhanced sub.py into a 4-stage visualizer (Original RGB, Canny Edges, Dynamic ROI, and Hough Lane Overlay) using Matplotlib subplots for diagnostics and educational demonstration.
  6. Comprehensive Unit Test Suite (test_lanes.py): Added 14 unit tests covering edge detection, ROI masking, coordinate generation, slope filtering, error handling, intermediate dictionary extraction, and end-to-end frame processing (100% pass rate).
  7. Standardized Documentation (README.md): Restructured documentation following README_TEMPLATE.md, including pipeline breakdown, installation instructions, full CLI reference, test commands, and project hierarchy.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation Update

Project

  • Your Project Name: Finding Lanes

  • Short Description: Computer vision road lane detection pipeline using OpenCV, NumPy, dynamic ROI masking, Hough line transform, and linear regression averaging.

Checklist:

  • I have named my files and folder, according to this project's guidelines.
  • My code follows the style guidelines of this project.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have created a helpful and easy to understand README.md, according to the given README_TEMPLATE.md.
  • My changes do not produce any warnings.
  • Added unit tests in test_lanes.py (14/14 passed).

@Prayas340 Prayas340 changed the title Fix/Finding Lanes path resolution, frame validation, line averaging, and README (#467) Fix(Finding_Lanes): Dynamic ROI, slope filtering, multi-source CLI, visualizer, unit tests & docs (#467) Aug 18, 2026
@Prayas340

Copy link
Copy Markdown
Author

?? Automated Testing & Verification Summary

All core functions and edge cases have been tested and verified:

`
test_average_lines_detection ......................... ok
test_average_lines_intercept_none_and_empty .......... ok
test_average_lines_slope_filtering ................... ok
test_canny_edge_detection ............................ ok
test_canny_grayscale_input ........................... ok
test_display_lines ................................... ok
test_display_lines_none .............................. ok
test_dynamic_roi_masking ............................. ok
test_make_coordinate_edge_cases ...................... ok
test_make_coordinate_valid ........................... ok
test_process_bundled_image_if_present ................ ok
test_process_frame_end_to_end ........................ ok
test_process_frame_intermediates ..................... ok
test_roi_custom_polygon .............................. ok

Ran 14 tests in 0.179s - OK
`

  • Video Stream Validation: Processed all 213 frames in video.mp4 with zero dropped frames or exceptions.
  • Static Image Validation: Processed picture.jpg with both left and right lane lines correctly extracted.
  • Headless & CLI Output: Tested --no-show and --output parameter handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Finding_Lanes] Fix ROI hardcoding, color space mismatch, line slope filtering, and add CLI & unit tests

1 participant