Now Reading
A Low Value Method to Bettering Pedestrian Security with Deep Studying

A Low Value Method to Bettering Pedestrian Security with Deep Studying

2023-04-27 07:43:06

TL;DR – Utilizing TensorFlow and a Raspberry Pi, I developed an affordable and correct means of counting each pedestrians and car visitors.

POST UPDATE: Since posting this, I’ve obtained a substantial quantity of curiosity from people and native metropolis governments from throughout the U.S. trying to get a greater grasp on pedestrian knowledge. Due to this, I spent a while constructing out a greater algorithm and packaging it for straightforward use. I am horrible with names, so for now it is merely “city mobility tracker”. Should you can consider a greater identify, please let me know! Moreover, to generate detections for the urban-mobility-tracker, I carried out a full mannequin retraining of MobileNetV1 SSD utilizing knowledge I collected and annotated. I am calling this new pedestrian/car/bicyclist optimized object detector “PedNet”. As time goes on and extra folks use these two instruments, I am hoping that individuals will contribute extra coaching knowledge (particularly in adversarial lighting and climate circumstances) in order that PedNet may be retrained and improved. Lastly, this new model continues to make use of TensorFlow however with the addition of the Coral USB accelerator which leverages Google’s TPU know-how so now it achieves an replace frequency of ~10Hz!!! (previous model was ~2Hz)

GitHub hyperlinks:
• City-Mobility-Tracker [here]• PedNet [here]


As somebody who bikes to work everyday, I’m conscious about how essential good city design and planning is and its affect on pedestrian security in addition to the general well-being of a neighborhood. I’m additionally conscious of how tough it’s to persuade automotive dependent, suburban commuters that we have to make investments our cash into bike lanes and curb extensions reasonably than lane extensions and parking tons. Due to this, I’m at all times a bit bummed after I see unfounded web shouting matches over why town ought to/shouldn’t implement bike and pedestrian security measures. We should always let the information determine what occurs, not ideology or private bias. Sadly, it’s this knowledge that’s laborious to come back by.

I bear in mind when shortly after the bike lanes on Central Pkwy had been put in, they had been searching for volunteers to face out within the baking solar all day and manually depend cyclists as they rode by. This struck me as comically old style but additionally a bit unhappy as a result of this was apparently the one approach to get the information on the time. Quick ahead nearly 5 years and the state of affairs seems to not have improved a lot. Beneath is an image I took just lately of some pneumatic tubes used to depend visitors.

pneumatic tube traffic counter

Determine 1: Pneumatic tube based mostly visitors counting

These are nice for quickly counting automobiles and different giant autos. Counting bikes, and pedestrians, not a lot… Once I rode over them that morning on my bike, I used to be indistinguishable from a bike. I’m an invisible bicycle owner, so why ought to town prioritize this street for a motorbike lane? Moreover, this setup was in place for lower than a day as a result of these tubes are held in place utilizing nails pounded into the street floor and bolstered with a pair strips of Kentucky chrome. Positively not ideally suited.

System Kind Value
SenSource pneumatic $695
RoadPod pneumatic $1,150
JAMAR TRAX I Plus pneumatic $2,600
Wavetronix SmartSensor HD radar $6,700
Miovision Applied sciences VCU video $3,700

Desk 1: Collection of visitors counting techniques

Though different counting techniques exist, they are typically overly costly, invasive, and unable to concurrently depend each pedestrians and car visitors. Cincinnati is stuffed with bikers, I see them day-after-day. But when they’re not being counted, we’ll by no means have the ability to overcome the suburban bias in Cincinnati’s city design and planning. With a greater counting system in place we are able to get the required knowledge to make knowledgeable selections that mirror actuality, leading to a fairer and extra equitable metropolis. If solely there was a low-cost, non-invasive answer that would passively depend all forms of visitors concurrently in any climate situation 24/7/365 and seamlessly push that info to the cloud on a minute by minute foundation…

My Answer

After occupied with this for some time, I made a decision that I might in all probability do a greater job than what at the moment exists. Provided that low-cost and excessive accuracy are my two main targets, I went with a Raspberry Pi Zero which is the smallest/least expensive of the Raspberry Pi fashions with the 8-megapixel v2 NoIR (infrared) digital camera and a chargeable usb battery pack. Since my system is imaginative and prescient based mostly it wants a transparent line of sight to the road but additionally by some means stay hidden from individuals who may tamper with it. Given these two contradictory constraints of being hidden but seen, I went with a stealth method. This was completed by shopping for a plastic weatherproof electrical field and reducing a gap on the entrance for the digital camera. The digital camera gap was sealed with a transparent lens filter. Lastly, I mounted six stupidly robust neodymium magnets on the again so I might connect it to road lights, signal posts, and so forth.

deep learning raspberry pi traffic tracker

Determine 2: My deep studying, raspberry pi based mostly visitors tracker

To truly depend pedestrians and car visitors I constructed out a convolutional neural network (CNN) with a secondary area proposal community (R-CNN) utilizing TensorFlow and Python. This permits for each the detection and localization of objects throughout the body. Precise object monitoring was completed utilizing a light-weight weight temporal clustering scheme utilizing NumPy and scikit-learn. For a extra in-depth look, click on [here] to learn the technical notes part.

deep learning raspberry pi traffic tracker in the wild

Determine 3: Hidden in plain sight – my child out within the wild!

After per week or so of informal coding I had a completed system. Provided that the monitoring algorithm is constructed on high of open-source software program, the one prices related to this technique come up from the {hardware} aspect.

Merchandise Value
Raspberry Pi Zero $10
Plastic electrical field $14
Magnets $18
128GB usb storage $28
USB Battery pack $40
Whole $110

Desk 2: Value breakdown of my Raspberry Pi based mostly system

For example of what all this seems to be like in motion, beneath is a gif displaying the monitoring algorithm when it was positioned at random spots all through Cincinnati.

deep learning raspberry pi traffic tracker in the wild

Determine 4: Monitoring visitors


To check my system out, I positioned it at few areas all through town. I began out by leaving it out within the area for twenty-four hours at a time. After I obtained snug with its efficiency I prolonged that length to a full week (normally Sunday evening to Sunday evening).

Determine 5: Central Pkwy location

For example of the information that this technique produces, beneath are the outcomes for when it was positioned on the Colerain Ave. bridge proper because it passes over Central Pkwy throughout August 23, 2018.

Determine 6: Car counts on Central Pkwy

As a result of the system generates a time stamp for every object because it passes over an imaginary “begin/end”, I binned all these knowledge factors into five-minute blocks. Moreover, despite the fact that car visitors may be additional damaged down by car kind, it was simpler to only group all autos right into a single class. Above in determine 6, we are able to see the inflow of southbound commuters coming into town throughout the morning rush in addition to once they go away within the night rush headed north. Car visitors peaked at 88 northbound autos per 5 minutes round 5:20pm. The day ended up with a complete of 6982 southbound and 7092 northbound autos travelling on this explicit section of Central Pkwy.

Determine 7: Bicycle counts on Central Pkwy

As a result of the frequency of bicycle and pedestrian visitors was a lot smaller relative to car visitors, it was simpler to show this knowledge from a cumulative perspective. Above in determine 7, the bicycle depend on Central Pkwy may be seen. Even with the cumulative kind, we are able to see a considerable amount of development throughout the southbound morning rush into town, however in comparison with car visitors, the night bicycle rush is extra subtle. Whole bicycle visitors for the day capped out at 56 and 57 for the northbound and southbound instructions respectively.

Determine 8: Pedestrian counts on Central Pkwy

Lastly, the pedestrian visitors may be seen above in determine 8. In contrast to each car and bicycle visitors, pedestrian visitors on Central Pkwy doesn’t have giant spikes throughout the morning / night rushes. As an alternative, pedestrian visitors is subtle pretty evenly all through the complete day.

Learnings and Future Enhancements

Over the span of this challenge I used to be capable of absolutely check the boundaries of this primary prototype and got here away with just a few key factors.

Algorithm Enhancements — Though the present two-part answer works, it’s removed from elegant and positively not essentially the most environment friendly answer. I’m actively constructing out a number of new deep studying based mostly options that mix the detection, localization, and monitoring right into a single operation inside TensorFlow Lite utilizing a MobileNets type framework. My hope is that these new variations will enhance efficiency throughout heavy occlusion or low mild whereas lowering computational overhead. In concept, if this had been ever carried out with permission from a metropolis (and thus solar-powered), I might doubtlessly use one thing extra power intensive equivalent to an NVIDIA Jetson or related IoT board. The mixture of the elevated horsepower, and decreased computational load would hopefully enable for a body price nearer to 10Hz reasonably than the present 2Hz.

Power Storage and Connectivity — As a result of I used to be flying below the radar throughout this challenge, I used to be restricted in two areas; power consumption and connectivity. Ideally I might have paired the 30,000mAh battery pack with a photo voltaic panel mounted on high. The photo voltaic panel would then energy the Raspberry Pi and cost the battery pack throughout the day, whereas the battery pack alone would energy it throughout the evening and thru overcast days.

See Also

The difficulty of connectivity would develop into the following impediment in long-term deployment. Because it at the moment stands, I take advantage of a 128GB usb reminiscence card to retailer all of the trajectory knowledge. I might have paid for a Raspberry Pi mobile knowledge plan, however I fully anticipated my prototype to get stolen. Given the perfect state of affairs of having the ability to hook up with an ethernet line, indefinite deployment turns into an precise chance.

Digicam Placement — After a bit trial and error, I found that the perfect place is ideally excessive over the middle of the road with not less than 100 yards of visibility. The hundred yards requirement was operate of the gradual body price of 2Hz. Presumably if I had quicker {hardware}, I might enhance the body price and cut back the required area of view. The elevation requirement is essential as a result of it reduces the occlusion, particularly when there are a number of lanes of visitors. Lastly, I at all times tried to place the digital camera in a loosely northward dealing with route and in shut proximity to a road mild. This allowed me to depend visitors at evening but additionally cut back the probabilities of incurring any glare or direct solar mild which might wash out the photographs throughout the day.

Thermal Administration — The present model depends on passive cooling as a result of climate sealing had the best precedence. Due to this limitation, I conservatively positioned it in areas that had been at all times shaded. This prevented me from measuring a number of street segments I used to be fascinated by but additionally compelled me to get inventive for others. If this had been ever carried out with permission from a metropolis, I might positively construct in a solar-powered fan for lowering mid-day warmth buildup.


General I used to be actually proud of the ultimate outcomes and I realized loads about deploying a self-contained system into the wild. It will be good to let this technique harvest knowledge for an prolonged time period in order that long-term developments may very well be precisely measured. With a system like this, a measurable affect of motorbike infrastructure funding may very well be generated. It might additionally present the underlying knowledge wanted to justify new infrastructure proposals.

deep learning raspberry pi traffic tracker in the wild

Determine 9: Me taking an image of a Raspberry Pi taking an image of me

Cincinnati authorities/division of transportation get at me. I wish to assist!

Technical Notes

Inside this part, I’ll cowl the technical particulars in-depth. There are solely a pair key elements to my system, primarily the algorithm, coaching knowledge, and {hardware}.

Knowledge — Utilizing labelImg, I manually annotated examples of every class. This was pretty time-consuming, however it gave me good chuck of time to catchup on podcasts so it actually wasn’t too unhealthy. I might have been substituted this guide knowledge annotation with current datasets such because the Caltech Pedestrian Detection Benchmark or one of many Daimler Pedestrian Benchmark Data Sets however one in all my main targets with this challenge was to begin at zero and end with a stable working answer. I used to be additionally involved with the discrepancy of coaching on full colour knowledge however working with the infrared knowledge coming from the v2 NoIR picture sensor. Lastly, I used to be additionally curious as as to if my dataset might assist overcome some identified shortcomings with reference to Quicker R-CNN., Beneath are the outcomes from my guide annotation. Be aware that pictures are captured and analyzed at 1280×720 decision.

Label Annotations (#)
Pedestrians 59
Bicycles 259
Vehicles 593
SUVs 217
Pickup Vehicles 137
Vehicles 229
All annotations 1494

Desk 3: Guide annotations (based mostly off 529 pictures)

Machine Studying — There are two main elements to the monitoring algorithm. The primary is the deep learning based mostly object detection and localization. For this I utilized a TensorFlow based mostly implementation of Quicker R-CNN, which is the brand new and improved model of Quick R-CNN, which is the brand new and improved model of R-CNN. This explicit implementation of Quicker R-CNN was constructed on high of Res-Net101 which had been educated on the COCO knowledge set. I might have went with a quicker single shot detection (SSD) framework equivalent to YOLO/YOLOv3, however I used to be extra involved with positional accuracy as a result of on the time my secondary objective was to measure car/pedestrian pace. Coaching was carried out utilizing the GeForce GTX 1050 GPU on my laptop computer which ended up taking roughly three hours.

The second element is the monitoring facet of the algorithm. As soon as the objects within the present time-frame have been detected and localized, they’re clustered utilizing k-means over a time window of three frames. At a picture seize price of 2Hz, this interprets to at least one second. This labored decently nicely for this preliminary prototype, however positively has its limitations. I contact on a number of methods by which this may be improved [here]. Beneath I made a basic stream chart depicting the monitoring course of.

temporal clustering

Determine 10: Monitoring system

{Hardware} — This preliminary model makes use of the v2 Pi NoIR 8-megapixel/1080p30 (Sony IMX219 sensor) digital camera paired with the Raspberry Pi Zero. The dearth of computing energy resulted within the monitoring algorithm unable to exceed a body price of 2Hz. All of this was powered by a 30,000mAh USB battery pack. In hindsight, I ought to have in all probability simply gotten the Raspberry Pi 3 B+ with some form of small industrial battery pack.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top