I wrote this lane departure warning (LDW) algorithm for my 2013 undergraduate thesis. Its only surviving copy was OpenCV 2.x C/C++ code printed in the PDF appendix. Thirteen years later, I restored that code, measured where its assumptions failed, and modernized one element at a time while retaining the evidence.

Road-video output from the restored legacy pipeline (public Udacity clip). Blue: detected lanes. Yellow: vanishing point and direction vector. Red: warning. The original logic is preserved: fixed ROI β Sobel/Canny β Hough β slope/distance filtering β vanishing-point estimation β fading-memory filter β warning after 2 consecutive frames.
Running the literal port on a public video 960px wide detected both lanes in only 11 frames out of 221. The cause was the 150px candidate-distance gate in the 2013 code: a hidden resolution assumption tied to the original 640px source video.
Absolute 150px threshold β both lanes detected in the 960px video in 11/221 frames (5%)
Scaling against the 640px reference width β same video: 221/221 frames (100%), with the original 640px behavior unchanged
This failure is documented in the repository README. The value of restoration lies in traceable root-cause analysis, beyond successful screenshots.

β Scroll horizontally. original β legacy restoration (2013 logic β Warning! false alarms flicker) β first modern (profile-based ROI + finite line-segment detection) β improved modern (control-state evaluation + gated ML).

A harder challenge clip with curves, shadows, and nearby traffic. While the legacy vanishing point fluctuates, the modern track exposes numerical detection confidence and state.
A lightweight ML lane-regression model is trained and runs on every frame, but its output is accepted only when it passes a segment-agreement gate against classical segment detection. It is accepted on most synthetic benchmark frames (the training domain), but on real road footage:
| Sample (real road) | Frames | ML run rate | ML acceptance rate | legacy warnings | improved states |
|---|---|---|---|---|---|
| udacity_solidWhiteRight | 221 | 100% | 0% | 0 | caution, normal |
| udacity_solidYellowLeft | 681 | 100% | 0% | 24 | caution, normal |
| udacity_challenge | 251 | 100% | 0% | 0 | caution, normal, unknown |
β the gate rejects every ML prediction. That is expected for a model trained only on synthetic data. The video overlay retains the evidence, for example ml rejected 0.36. The claim is that I built a system where ML outputs can replace classical detections only through measurable adapters and safeguards. The lightweight model is not presented as a production lane detector. Real models such as UFLD/ONNX can reuse the same adapter and evaluation pipeline.
GitHub repository (code, tests, and documentation) β Portfolio home