SpeedCam – Getting the Data

I recently got to be in be on the news for a fun project (see the bottom of the article for the video).  We have had issues with cars speeding down our street.  I have had the traffic department place the street sign that showed your speed down the street.  This did give us some data, but people seeing the signs changed their driving during that drive only.

Being a person that works with data, I thought there has to be a way to track this data source.  I tried to build my own system to track the cars going by.  After trying a few different things, Arduino and Raspberry Pi, I started reading on using a webcams to track cars.

My setup is as followed:
Camera: HIKVision IP Camera (but a USB camera will work also as shown in the news video)
Power Injector: TP-LINK TL-PoE150S
Computer: Dell Laptop running Windows 10
Speed Camera Software: SpeedCam AI
Data Analyst Tool: Splunk

I tried a few different programs and found SpeedCam AI.  This program let me draw a rectangle and define the distance.  I know that the sections of the street are 15 feet (4.572 meters) in length.

I set up two different lanes.  Lane 1 is for West bound traffic and Lane 2 is for East bound traffic.  In the settings you can specify what the delimiter.  You can also use the software to save a picture of the vehicle, and clean up the reports.

With SpeedCam AI writing the details of traffic to a csv file, Splunk can easily ingest the data.

Installing Splunk on Windows
Installing Splunk on Linux

Adding the data to Splunk:
Once you log in to Splunk, you should see an “Add Data” button.

There is a couple options for bringing the data in.  Select “Monitor” to be able to continuously bring in the data.

You will then want to select “Files & Directories”.

Click “Browse” to select your “reports.csv” file and then click “Next”.

You should see a preview of your data.  You will see that Splunk has identified the data in a csv file.  Since the file doesn’t have a header row, you will need to give it one.  In the delimited settings, in the Field names section, click Custom.  In this example I used “datestamp,lane,speed,speedLabel”.  Then click next to continue.

It should prompt you to save your custom sourcetype.  Click Save.

I gave the sourcetype name as “speedcam”.  I then gave it a description and left the category and app the defaults and then click Save.

On the next page we can set the hostname for the data stream. Normally you can leave this the default. In a production environment, we would also want to choose our index. For this example, I am going to leave it as “Default”. At this point we can click “Review”.

You can review the setting and then click Submit and it will start bringing in your data.

For the Command Line People
## inputs.conf ##
[monitor://c:\program files(86)\SpeedCam\reports\reports.csv]
sourcetype = speedcam

## props.conf ##
FIELD_NAMES = datestamp,lane,speed,speedLabel

At this point, you have the SpeedCam AI software running and Splunk bringing the data in.  I will follow up with another post on the Splunk App I have written.  In the mean time, here are a few videos on searching and reporting in Splunk.

Basic Searching in Splunk
Creating Reports in Splunk Enterprise
Create Dashboards in Splunk Enterprise

12 thoughts on “SpeedCam – Getting the Data

  1. Did you guys have any luck using an IP camera and ONVIF? Mine works using a USB camera, but when I configure to use an IP camera, i receive video, but then the frame freezes. I have swapped PC’s, cameras, all the same result.

    • I had to switch to the sub-video feed. I really don’t like using the sub-video as it is 640×360 at 15fps. If I were able to use the main video feed I could use 1920×1080 at 30fps or 2688×1520 at 20fps. I have a HIKVision DS-2CD2142FWD-IS. Below are my connection strings.

      Main Video using ONVIF:

      Sub-Video Feed:

  2. Hi, Anthony. Thank you very much for your write-up; I found it quite helpful. We have a similar issue in my residential neighborhood, which borders a state highway. Limit is 30, but drivers (including fully loaded triaxle dump trucks) routinely rip through here at 50 – 60 MPH. Worse, the state police (it’s their jurisdiction) have indicated that they currently have no intention of devoting resources to speed enforcement here, so I’m hoping to find a way to use Speedcam AI as a bit of a goad. I think it would be of great benefit if a license plate photo could be taken and correlated with the speeding vehicle. Does the software make any provision for this (from the angle of the example photos it doesn’t appear that the plate would likely be captured)? If not, can you think of any relatively easy way to tie in an additional camera in such a way that it that would take a license plate photo that could be correlated with the speed records? Thanks.

    • Sam,

      I have taken down my system but I was researching this before I did. I took my system down due to frustration. The local police department was doing everything they could but they are bound by time and resources. I was directly working with the Sergeant in charge of all traffic enforcement in the area. He acknowledged that our area, as well as many other areas in town, have a speeding problem. They can only have an officer in the area for so many hours. Since the data shows when the times that most people were speeding, they were able to schedule when an officer could be in the area. The data then showed that the behavior didn’t change after the officer wrote tickets. And that is where the frustration came from.

      As for the license plate reader system, I was look at some software called OpenALPR. I was going to tie the two systems using Splunk since I have the Speedcam AI data in Splunk already. There is a free plan for OpenALPR. The camera will need a good nearly straight on view to best be able to make out the license plate data.

      Otherwise there are cameras specifically designed for capturing license plates. A quick search on Amazon shows a bunch but be careful of the sub-$200 cameras. They will read license plates at slow speed. They are designed for parking lots and typically when you stop at the cross bar. You will want to look for cameras that list what the speed rating is for capture. This camera (link) shows that it is rated for 90 km/h or 56 mp/h.

      If you get a setup going, please send me pictures and a layout of your design. I am always interested in the different ways people solve problems.

      ** Things of Note **

      • When you are putting up cameras, remember to check local laws for filming and recording information. It might be different from video recording of the vehicles to recording of the license plate information. Then there is the public/private road details.
      • Provide the evidence of speed and show them how you collected the data. Invite them to compare their Laser speed gun to your video system. I found that I was around +/- 1.5mp/h. Talking to officers, the laser speed guns are around .5 to 1 mp/h off.
  3. Anthony,
    I think you may have given up too easily. Police, like everyone else, respond to incentives. Currently yours evidently have greater incentives for other kinds of enforcement. If those other activities are also higher priorities for you, then that’s fine. But, more likely, they reflect higher priorities for politicos and politically-connected parties, who may share no interests at all with you. Frankly, I find it difficult to believe that a concerted effort at issuing traffic summonses would have no beneficial effect. Here, I was told that the state police have been instructed not to write speeding/traffic tickets on this road for fear of annoying the tourist trade. The result is no enforcement at all. There is even a public school bus that comes through here at twice (my guesstimate) the limit twice every weekday.
    Once the photos are in hand, there are a number of possible tactics if the police don’t respond adequately. You could begin swearing out complaints against the owners of the autos. That would require the license plate photos, and the cooperation of the police to research the owners, but I think that in some places cooperation is compulsory in response to a formal complaint. That tactic may not produce direct results, but the police could decide that it is less trouble to do more enforcement than to deal with your constant, annoying, presence (of course, you could experience retaliation yourself, ymmv). You could also take the campaign to a local newspaper, complete with photo evidence. Attending local government meetings to raise the issue might help. Create enough of a public hue and cry, and there will be a response. Hopefully that response is directed toward making the problem go away, not the messenger, Finally, without making it seem to be a direct threat (threatening police with consequences for their actions or inaction is nearly always hazardous to your health and well-being) let the police know that if there should be some kind of horrible, speed-related, accident on that stretch of road, you would be forced to publicize your efforts to get effective enforcement and the limited cooperation with same. It probably wouldn’t hurt to use the word “children” multiple times in that conversation – it seems to work reliably for politicians.

  4. Another thought occurred to me. There are various internet pages and forums that purport to identify stretches of road that regularly feature speed-traps. If your problem area is on a highway or through street of some kind (as is mine) I’d be willing to bet that a concerted effort could get it listed in a number of those places. It might require some, um, embellishment, but if it became common knowledge (true or not) that this was the case on your road, an effect might be seen. Don’t forget that unless traffic is very sparse, not every driver needs to drive at or near the limit. One driver observing that limit can keep several others from speeding.

  5. Does anyone know if this company is still active and supporting the product? I’ve contacted their support with no response.

  6. Hi, I have been planning on integrating the speed-camera data with splunk and came across this page. I know that you stopped working on it but do you still have the app so that I don’t have to recreate the wheel?

Leave a Reply

Your email address will not be published. Required fields are marked *