Computer Vision Β· Restoration Β· Evidenced Modernization

My algorithm from 2013,
rebuilt with the discipline of 2026

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.

01

Restoration β€” the 2013 logic runs again

Legacy restoration: blue lanes, yellow vanishing-point vector, red Warning

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.

The goal is to make my design decisions from 13 years ago auditable through modular code, typed dataclasses, 18 unit tests, a CLI, and per-frame metrics CSVs, beyond simply detecting lanes.
02

The first failure β€” and its root cause

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.

Literal port (hidden assumption preserved)

Absolute 150px threshold β†’ both lanes detected in the 960px video in 11/221 frames (5%)

Correction (assumption made explicit)

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.

03

Four-panel comparison β€” the same frame, three generations of the algorithm

Four-panel comparison: original | legacy | first modern | improved modern

← 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).

Four-panel comparison of the challenge clip with curves and shadows

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.

04

ML stays behind a gate β€” integration aware of domain shift

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)FramesML run rateML acceptance ratelegacy warningsimproved states
udacity_solidWhiteRight221100%0%0caution, normal
udacity_solidYellowLeft681100%0%24caution, normal
udacity_challenge251100%0%0caution, 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.

This follows the same principle as my other projects: tools over tokens, models behind gates. In domains with low error tolerance, learned models should influence decisions only through verifiable paths.
05

Why this project

GitHub repository (code, tests, and documentation) ← Portfolio home