Riding a motorcycle without wearing a helmet is a dangerous decision that can have serious consequences. Helmets are essential safety gear that protect the head and brain in the event of an accident, reducing the risk of fatal or life-altering injuries. And the statistics bear that out — they consistently demonstrate just how important the use of a helmet is in preventing serious harm.
According to the World Health Organization, wearing a helmet can decrease the risk of a fatal head injury by as much as 40% and reduce the risk of severe injury by approximately 70%. In countries where helmet laws are strictly enforced, there is a noticeable decline in motorcycle-related fatalities compared to those where helmet use is not mandated or regularly observed.
In addition to preventing fatalities, helmets play a crucial role in minimizing the severity of head injuries. Traumatic brain injuries resulting from motorcycle accidents often lead to long-term disabilities and can significantly impact the quality of life for both the rider and their families. The economic costs associated with these injuries, including medical expenses and ongoing care, are substantial.
People have many reasons for not wearing helmets that range from simple forgetfulness to being unaware of just how much danger they are putting themselves in. Whatever the reason may be, engineer and machine learning enthusiast Roni Bandini dreams of a future where unnecessary injuries are much less common than they are today. Towards this goal, he has developed a prototype system of a clever solution that could one day help to curb compliance issues with motorcycle safety laws.
Bandini’s idea revolves around the use of a computer vision algorithm to detect whether or not motorcyclists are wearing a helmet. He reasons that with this information, the normal pattern of a traffic light could be interrupted. In particular, Bandini’s goal is to prevent a red light from changing back to green when an unsafe driver is recognized.
Picking out a specific feature from an image is a perfect job for an object detection algorithm, however, it can be quite challenging to build, train, and deploy these types of models — especially on the types of mobile platforms that need to be used for a real-world installation. To take the complexity out of the equation and instead focus on solving important problems, Bandini chose to use Edge Impulse to develop the object detection model.
Mobile computer vision systems need to strike a delicate balance between the energy efficiency required of a portable device, and the relatively high computational requirements of processing a stream of video. Highly optimized algorithms are a good start, but careful selection of an appropriate hardware platform is also essential. Given these constraints, Bandini selected a Texas Instruments AM62A Starter Kit for the project. This board comes standard with an AM62A AI vision processor that makes short work of processing image frames. And with an onboard AI accelerator, up to two trillion operations per second can be performed. In spite of all this power, the AM62A still slowly sips power, making it ideal for edge AI applications.
Getting access to a real traffic light for development purposes is a bit out of reach for most hobbyists, so Bandini instead built a scale model, complete with Lego motorcyclists and a simulated traffic light displayed on the LCD screen of a UNIHIKER single board computer. He collected images with this setup to use as training data. After snapping some pictures of Lego figures with and without helmets, he uploaded the files to a project in Edge Impulse using the Data Acquisition tool. He then leveraged the AI-assisted Labeling Queue to quickly draw bounding boxes around the objects of interest — helmets and bare heads.
With the training data in hand, Bandini was ready to build the object detection analysis pipeline using the Create Impulse tool. An impulse defines all of the steps involved in handling data, from the time it is collected from the sensor until a prediction is made by the model. In this case, the impulse began with a step that resized the images. This is important to reduce the amount of computational resources that are needed in downstream steps. The data was then reformatted and forwarded into a neural network that was designed for object detection. Finally, that model will provide a “helmet” or “no helmet” prediction as it encounters new data.
The training process was kicked off after completing the impulse design. A short time later, metrics were presented to help in assessing how well the model was performing. It was discovered that helmet status could be accurately determined in greater than 95% of cases on average. That is more than good enough for a proof of concept, so it was time to deploy the analysis pipeline to the physical hardware.
Bandini next loaded the operating system image onto the AM62A Starter Kit, and then installed Edge Impulse for Linux on the device. This downloaded and installed the object detection pipeline after issuing just a few commands. Next, Bandini added some custom code that wirelessly triggered the UNIHIKER-based traffic light to alter its behavior based on the inference results produced by the helmet detector.
While there are some considerations that could prevent a system like this from being deployed in the real-world — like the fact that other drivers behind the biker would also be delayed, or the fact that some offenders may have no helmet available to put on, leaving them permanently stranded — this project shows how simple it is to rapidly build a complex computer vision-based device using Edge Impulse and modern edge computing hardware. Given the speed with which one can iterate on a design using these methods, perhaps a more suitable solution could be arrived at in short order.
If you would like more information about this system, or would like to build your own copy of it, Bandini has written up detailed documentation. The Edge Impulse project has also been made public to give you a head start in creating your own computer vision applications.