Drivers Are Breaking the Law, Slowing Commutes and Endangering Lives. I Can Prove It — And Fix It.

Alex Bell
5 min readMar 15, 2018

--

New Yorkers who take the bus or ride a bicycle know that one of the most infuriating and dangerous aspects of their trip is cars and trucks parked in a designated bicycle- or bus-only lane. These illegally-parked vehicles slow commute times and contribute to congestion by forcing buses to stop and merge into another traffic lane and force bicycle riders into traffic, jeopardizing their safety and antagonizing drivers.

Every day, hundreds of thousands of commuters are slowed and inconvenienced so that a small minority of drivers can walk a little less. It’s unfair and unsafe.

We must — and can — do better.

I built a machine learning algorithm, using publicly-available image data from the New York City Department of Transportation, to study bus- and bicycle-lane blockage in New York. The results prove the severity of New York’s traffic enforcement crisis, and offer meaningful insights into how we can quickly, affordably, and equitably get traffic moving again.

A Test

While there’s plenty of anecdotal evidence detailing how little bus- and bicycle-lanes are enforced, I wanted to examine the problem with a more rigorous approach. The New York City Department of Transportation (NYC DOT) maintains several hundred traffic cameras throughout the city, which post images in real time to dotsignals.org.

To pick just one example, I took a look at the camera on the corner of 145th Street and St. Nicholas Avenue in Manhattan. St. Nicholas Avenue has unprotected bike lanes in both directions, features a bus stop, and is near a police station. (Images from this camera are available here.)

I then wrote a computer algorithm using machine learning, available here (in short, a pre-trained Tensorflow model was re-trained on approximately 2000 pre-classified images) to study the video for ten days in December 2017, and classify the vehicles on the road and where they parked.

The Results

From 7 a.m. to 7 p.m. on weekdays during the period of study, the bicycle lane in front of the traffic camera was blocked 57 percent of the time, and the bus stop was blocked 55 percent of the time. Across the full ten-day period, 24 hours a day, the bicycle lane was blocked 40 percent of the time, and the bus stop was blocked 57 percent of the time.

This is just a one-block snapshot of a problem that spans all five boroughs. Bicyclists frequently have to swerve into traffic to get around vehicles. More often than not, buses have to park far from the curb, blocking traffic and forcing riders into traffic. Disabled bus riders can’t safely board, and the bus is slowed down as passengers have to thread between parked cars to get on and off the bus.

What’s Next?

This investigation definitively shows that a small number of drivers are wreaking havoc on New York City streets. But this system also offers the city a tool to equitably enforce its existing traffic laws, reduce congestion, and increase safety for drivers, bicyclists, pedestrians, and public transit riders. The City should build off of this research and evaluate the feasibility of installing four cameras at every intersection in the city. The camera feeds should be higher quality but blur faces onboard the camera to preserve privacy, and the city should build and maintain an open source system to process the video feeds using machine learning to identify moving and parking violations.

Such a system, if implemented well, would cost less and be more effective — and more equitable — than the current system. Once the problem is wholly quantified, the City should look at expanding the program to read license plates and ticket lane-blockers after a certain, reasonable amount of time.

This setup could also potentially provide a number of research, policy, and enforcement resources for the city. Researchers may be able to use the open camera system to quantify how blocked bus lanes slow traffic and bus speed; determine best practices for snow plow and emergency vehicles; study bicyclist behavior; and count traffic, vehicle speed, pedestrian density, and bicyclists. This program could also be used to quantify and enforce 53-foot truck violations, parking placard violations, and taxi and livery violations.

Technical Footnotes:

The github page has all the code.

Some general things learned.

  1. My Intel Core i7–4770K took about 24 hours to retrain the last layer of the model. I thought it would take longer and I would need to use cloud GPU’s.
  2. Tensorflow was really easy to get started using. I had taken some Machine Learning classes 8 years ago and things are getting easier and easier to get started.
  3. I had 800,000 images to process with the model to look for vehicle positions. Each 352x240 image took 5 seconds to analyze on my Intel Core i7–4770K CPU only. I thought it would be faster. I ended up using Amazon AWS p2.xlarge with 1 Nvidia K80 and it took .3 seconds per image. I also thought that would be faster.
  4. As you can see in the code the determining of whether or not the vehicle is in breach of the traffic law was not done with machine learning. Instead I just drew a simple polygon representing bus and bike lanes and counted a vehicle as blocking if it was the correct type of vehicle, i.e. not a bus, and whether the center of the vehicle was in the lane.
  5. I considered training the algorithm to try to spot bike lanes and bus stops and do its own determination. But I was concerned that with the street markings barely visible it would be very difficult. So instead, I just drew the lanes because I could visit the street and determine the actual markings. If this was to be used at scale there might have to be a manual portion of drawing or determining the lanes/stops and mapping that to pixels.

--

--