Homebrew Traffic Monitor Keeps Eyes On The Streets

How many cars go down your street each day? How fast were they going? What about folks out on a walk or people riding bikes? It’s not an easy question to answer, as most of us have better things to do than watch the street all day and keep a tally. But at the same time, this is critically important data from an urban planning perspective.

Of course, you could just leave it to City Hall to figure out this sort of thing. But what if you want to get a speed bump or a traffic light added to your neighborhood? Being able to collect your own localized traffic data could certainly come in handy, which is where TrafficMonitor.ai from [glossyio] comes in.

This open-source system allows the user to deploy an affordable monitoring device that will identify vehicles and pedestrians using a combination of machine learning object detection and Doppler radar. The system not only collects images of all the objects that pass by but can even determine their speed and direction. The data is stored and processed locally and presented via a number of graphs through the system’s web-based user interface.

While [glossyio] hopes to sell kits and even pre-built monitors at some point, you’ll have to build the hardware yourself for now. The documentation recommends a Raspberry Pi 5 for the brains of your monitor, backed up by a Coral AI Tensor Processing Unit (TPU) to help process the images coming in via the Pi Camera Module 3.

Technically, the OPS243-A Doppler radar sensor is listed as optional if you’re on a tight budget, but it looks like you’ll lose speed and direction sensing without it. Additionally, there’s support for adding an air quality sensor to see what all those passing cars are leaving behind.

This isn’t the first time we’ve seen the Raspberry Pi used as an electronic traffic cop, but it’s undoubtedly the most polished version of the concept we’ve come across. You might consider passive radar, too.

52 thoughts on “Homebrew Traffic Monitor Keeps Eyes On The Streets

    1. Speed bumps mostly keep the residents awake at night. As the silent rolling is exchanged for heavy thudding. Soon every neighbour will turn against the requester of them, just as you said. Though civilized people condone and despise violence.

      1. Sound has literally never been a complaint with speed bumps in my area, and there’s tens in each road. However people do rightly complain that their suspension is falling apart and the 30mph road is now effectively a 15mph road because the bumps are too harsh, plus the traffic now speeds up to 40 between bumps to make up the average time. They’re a false win.

    2. or worse, a stop sign! My inlaws’ house has a stop sign right in front and people either run it entirely, defeating the purpose, or slow down (never ever actually stop) and accelerate away and occasionally peel out at all hours of the day and night. It is definitely a first world problem but if I lived there I would move. And I lived in NYC for a long time, I’m not particularly noise sensitive.

        1. There are no accidents, just:
          1. Mistakes by one or more parties to recognize or mitigate the situation
          2. Due to Skill (or lack thereof)
          3. Whereby speed determines the penalty to be paid due to #1 and #2.

          Focusing on speed without context of skill is race to the bottom. Horse and buggy? Or bicycles mostly for progressives.

    3. You guys should talk to someone who lives on/near a hill with the traffic humps.
      Every old four-banger (that hasn’t finally popped an over-due timing belt at 6k rpm) with a fart cannon exhaust, that somehow needs to tap dance on the throttle to get over the lump.
      Or the torn up yard from people trying to drive around them because their cars scrape. Some people move their mail boxes to beside of the bump, looking to stop the go-arounds.

      1. I maintain my car and since I’m not on Instagram, it’s not a fart-cannon. Still, my Mazda BP-Z3 engine popping a timing belt would at most be an inconvenience, not a disaster thanks to its non-interference design.

    1. I think I looked at that as an idea for traffic monitoring previously – IIRC the problem was that TPMS sensors didn’t transmit regularly enough to reliably detect a vehicle as it swings by.
      I’d be keen to hear whether I’ve gotten that wrong though.

      1. There are several commercial products that track vehicles using tpms.
        Some shady company is getting away with charging my city for supplying “traffic data” they collect from a shin-high box on every telephone pole.

        That same company sells tons of data to the big data brokers.
        This kind of data is the stuff you really should feel uncomfortable about.

        I know this, because I periodically purchased “profiles” of family members for years to see how much stuff was being collected, and to more accurately get stuff removed.

        I don’t know how YOU define “personally identifiable information”, but having the already publicly available info about what car you drive combined with the route you drive it, where you park it for X hours on weekdays (your job), where you park it at night(your home), the stores/businesses you frequent, and a slew of other “interred” data you can get from the constant tracking of your vehicles location? That’s pretty “personal” IMO.

    1. oops wrong button, this comment was meant as a reply to the comment of “sword”.
      Well… this comment is here forever now, no way to make it go away.

      Imagine a world where a comment could be removed or edited, the future could be so bright.

    2. Because they are a huge minority of cars on the road today? The percentage missed works out to a rounding error. Especially if you are simply trying to collect enough data for a city to do something.

      1. The average age of cars in the US is 14 years (since you’re so US focused). Which means half the cars on the road were made before 2010. You pointed out that TPMS was mandated in 2008. Perhaps this a unusual definition of the term “rounding error” with which I am unfamiliar.

  1. Love the idea. The radar chip is pretty expensive though. I wonder how well they could do at speed estimation using only a few frames of the camera instead. You would have to calibrate it for residential speeds though it’s probably a reasonable error rate. Hm. I think if they got creative the cv aspect of this could be done on more limited hardware too. Either way what an awesome cv project! Has me thinking about making one.

    1. The security camera software I use (Agent DVR) has a “Speed” detector you can use (instead of object tracking, motion, etc) which does this. I don’t know how reliable it is, as I don’t use it and my cameras don’t quite capture enough road. But at least some folks are thinking about it.

    2. yeah if the camera is fixed well enough, then it’s easy to calibrate the distances…just measure off some amount of roadway using a measuring wheel (or bicycle speedometer) and mark the endpoints in your image.

    3. Thanks for the interest! The radar easily doubles a build cost. It is certified with the same test as police speed guns, so it has the authoritative tech, which is important for some advocates looking to bring data to municipalities. However, I could easily see adding an “AI estimated speed” just based on cameras… Several companies have traffic monitors doing just that. I haven’t found an open algorithm for that, so it would be on my list to add to the project and open source–any interest in contributing? :). I also shared the 3D model for the enclosure, in the docs for printing: https://docs.trafficmonitor.ai/build-your-own-device-diy/recommended-hardware#enclosure-weather-resistant-box

  2. Is this actually legal in US? In most European countries, this would be illegal – you can’t record public spaces without special permission. Also, it’s creepy – this detects cars, the next thing is license plates? And than? Facial recognition? Not OK.

    1. Yes, in the USA (at the moment) recording in public is generally allowed. There’s some differing laws about audio recording – under “wiretapping” laws – but video is typically fair play. And there are open source ALPR and face recognition solutions for the other things. Not saying it’s a good or bad thing, it’s just how it is.

    2. It’s only illegal because it’s being recorded with personal info. If the data was abstracted from personal info (i.e. no photos stored, no number plates stored) then only type/datestamp were stored, there would be no GDPR breach. You’re allowed to photograph public places, there’s no expectation of privacy in a public place.

      1. i think it’s a bit more complicated: you’re allowed to photograph public places but video surveillance is a whole different matter and it’s heavily regulated. recording a public street 24/7 is definitely against the GDPR.
        and even if you’re not storing data (e.g. processing the images live and not storing them) you’re probably still handling personal data, which falls under GDPR rules.

        1. Ok so this may be country dependent – where i live (CZ) it was illegal before GDPR – it was allowed to monitor (though that is sort of a grey zone), but recording was not legal before GDPR and is not legal now. If you have CCTV system with recording, which may record parts of public space like street, those parts must not be recorded (many DVRs have options to black out certain parts of the frame for this purpose). What GDPR adds is when you record as a business – like in a shopping mall or gas station – you must provide information about how, where and for how long the recordings are stored, who has access and for what purpose are they used (and you still need a permit, but in this case, it is just a formality).

          Do people sometimes record portions of the street in front of their house because they are just fed up with some stupid person damaging their car or something? Yes. Is that actually legal? No. But at least it is about protection of their property. Monitoring passing by random cars is just creepy.

          There was some discussion about dash cams – up to the point that some police officers outright rejects recordings from those as “illegal” during car crash investigation. Though some others will accept them and people do use them and i haven’t heard about anybody getting fined for using them – so they are kind of accepted as ok.

      2. There’s also specific rules about CCTV which are probably relevant to this.
        People have been taken to court over ring doorbells which see a bit more than they need to, so it’s probably worth checking carefully.

    3. According to the “auditors” on the various video services, in the USA you can record anyone anytime anywhere provided you are recording FROM a public space, or private space with permission, including inside government buildings or any open to the public.

    4. it varies. i know where i am in the US, there’s some regulation about recording away from your home if you aren’t present. so if you want to set up a traffic monitor on an arbitrary street corner, you should be physically present yourself while it’s operating. but generally, anything you can see from your windows is considered fair game. i’m sure the rules would change under your feet if you deployed this massively, like as a crowdsourced thing.

      i don’t think it’s creepy. traffic is a serious hazard to the neighborhood it passes through. monitoring people who are doing violence is fair game, morally.

    5. I totally agree with the privacy concerns. It is actually one of the reasons I built this: as an education tool… What can it do? How can these activities be made more private? What can you expect from police, security companies, etc? e.g. using local inferencing, only keeping the metadata about events, avoiding sending PII to the cloud, auditing AI/ML capabilities, etc.

      And, if someone: a municipality, police precinct or organization does get permission to have traffic cams or speed safety cameras for any purpose, what options do they have? Most vendors are closed-source, cloud-based, and dubious on privacy. Open tools could change the conversation and make the tech decentralized so one vendor or government doesn’t have all the keys to the castle. Was thinking of this organization, specifically: https://ggwash.org/view/90697/its-time-to-think-different-about-automated-traffic-enforcement

    6. I am actually going to build and tweak this. I am already for several years fighting with our municipality over enforcing speed limit, regularly people driving 70kmh on 50kmh, where there are 3 pedestrian crossings and kindergarten in vicinity. As long I will not take photos but only statistics with radar I will be completely ok. it will not record and no posibility to realtime look on video stream so public space recording does not count.

  3. Got to remember that Americas’ business ecomomy is heavily based on data collection and parsing it out for a fee. Even your medical info is up for trade here, aka, “our partners and/or affiliates”.

    1. This is so true it hurts. I found out hard way that the state medical board sells your information to advertisers, solicitors, head hunter agencies, and the like. The state run mandatory, legal licensing entity without which you cannot do business without going to jail, mandates you pay hundreds of dollars for the license, then sells all you personal information to anyone willing to pay.

    2. Agree with that… 💯 What’s the saying? “If you get the product for free, then you’re the product.”
      On top of that, the mechanism to collect that data is often subsidized by the public and not available to the public. In that case, the public should have the chance to see and impact how that data is collected and use relative to individuals’ privacy; i.e. data openness and transparency. I am interested in the work by ODC (https://opendatacharter.org) on that topic.

      Since you mentioned medical: Even healthcare data can be de-identified and sold without violating [HIPAA] privacy rules (https://www.hhs.gov/hipaa/for-professionals/special-topics/de-identification/index.html), and the more a company has, the more valuable it is. So, even with an ostensibly safe preparation of the data, everyone’s interactions are monetarily valuable. We need a balance between data use for decision making / public health / policy making and rent-seeking.

  4. Some guy put one of these on the interstate to pennsylvania and used it as a plate reader.
    He then runs the plate through something to get cars VINs, then uses those to get to names, then goes from names to phone numbers, then sends fake toll payment text messages.
    it would be cool to foxhunt the thing and light on fire.

  5. Interesting that where I’m at, the city still uses the old rubber hose pneumatic type counters for traffic counts. Seems that would help cover the privacy rules.
    But then they also have a very active campaign for getting people to allow city access to your “security” cameras?
    The traffic cameras (mounted at intersections, paused car allows a better image.) that “would only ever be used for traffic management”. They adamantly swore they would never be human readable. You can probably guess how that went.

Leave a Reply to HelenaCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.