Quantifying New York's Surge in Illegal Mopeds Using Computer Vision

A version of this research was published in the journal Vital City. I’ve also posted the code/data if you’re interested.

tl;dr

I trained a custom object detection model using data collected ad hoc from a network of traffic cameras in an attempt to quantify the deluge of illegal gas-powered mopeds operating on New York’s streets. I recorded over a thousand mopeds driving illegally and dangerously, and focused on a particularly concerning situation developing on an already congested bridge crossing.

mopeds found using object detection
Results from the object detection model

Background

New York City’s streets have seen a surge of e-bikes and illegal gas-powered mopeds in recent years, mostly caused by an increase in use of food delivery apps. There are a host of problems associated with the industry as it is currently configured, but I focused on the effects on street safety. While delivery workers initially chose e-bikes, a string of high-profile fires caused by substandard batteries and high costs mean more and more are switching to gas-powered mopeds. The vast majority of these are not registered and do not have license plates, making them illegal. The gas-powered mopeds are heavier and are faster, both factors that contribute to worse outcomes in the event of a crash. Drivers frequently illegally ride in the bike lane, on sidewalks or against the flow of traffic. While there is no data specifically on mopeds, there has been a flurry of anecdotal evidence of crashes and close calls, with some people deciding to forgo cycling in response. All of this has created a dangerous situation on New York’s already densely packed streets.

Data and Methods

The New York City Department of Transportation (DOT) maintains a network of cameras designed to monitor traffic conditions. These cameras produce a still image every two to four seconds, there is no video and images are not retained. Although access to the DOT camera feeds is supposed to be available to the public, I was not given access despite repeated attempts. To overcome this bureaucratic obstacle, I built a simple web scraper to download static images. My script cycles through a list of cameras and capture various locations where a bike lane is visible in the frame. This method ensured minimal loss of information since the cameras only produce still images every few seconds. The web scraper organized images by location, date and time to ensure accurate reporting of results, especially since time stamps displayed on the images were sometimes incorrect. Cameras were stored in a dictionary where the the camera name was they key and the url for the feed were the values.

response = requests.get(url, stream=True)
response.raise_for_status()

timestamp = time.strftime("%Y%m%d_%H%M%S")
image_filepath = img_path / cam / f"{cam}_{timestamp}.jpg"
os.makedirs(img_path / cam , exist_ok=True)

with open(image_filepath, "wb") as file:
    file.write(response.content)

I collected images in three hour blocks in the afternoon, partially overlapping with rush hour, for one week in autumn. After collecting the images I created a custom dataset using Roboflow to draw bounding boxes and create additional images (modifying existing images with techniques like shear, reversing or adding noise) and trained a custom YOLOv8 model. The model achieved a mAP50 of 0.9 and a mAP50-95 of 0.6, which as you will see was sufficient for this task.

Results

I found over a thousand instances of mopeds operating illegally in Manhattan and Brooklyn, the most dense and most populous boroughs respectively. The object detection model revealed mopeds riding in bike lanes, pedestrian plazas and across bridges, all spaces that prohibit motorized vehicles. It’s imperfect but allows us to begin to understand the problem and formulate solutions beyond occasional police stings that create a severe financial burden for delivery workers, already some of the most vulnerable New Yorkers. There were severe limitations which I address in the next section, but after reviewing the initial results from the model, I decided to focus on one particularly dangerous area where camera placement was optimal: the Manhattan entrance to the shared pedestrian/bicycle path across the 59th Street/Queensboro Bridge. This bike path forces pedestrians and bicycles to share one narrow lane for travel in both directions, and now increasingly includes fast-moving e-bikes and illegal mopeds.

mopeds found using object detection
Mopeds illegally using the 59th Street/Queensboro Bridge bike lane

I recorded one moped roughly every five minutes using the narrow span. That essentially guarantees encountering a gas-powered moped since it typically takes longer to cross the bridge by foot or bicycle. I also recorded about 50 mopeds using the bike lane on the iconic Brooklyn Bridge, seemingly undeterred by the police cruiser permanently stationed at the foot of the Brooklyn side of the path.

Next Steps, Improvements, Recommendations

The major limitation in this project was the image quality of the cameras which was only 352 x 240 pixels. Static images are also far inferior to video, which would allow for object tracking and speed estimation to further bolster results. Ultimately this was a proof of concept using a network of cameras designed for a very different purpose, mainly monitoring the traffic flow of cars. The technology already exists to create an improved version of the model, it just needs to be implemented. Here are some other thoughts and recommendations: