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 ##
[speedcam]
INDEXED_EXTRACTIONS = CSV
FIELD_DELIMITER = ,
FIELD_NAMES = datestamp,lane,speed,speedLabel
CHECK_FOR_HEADER = false
SHOULD_LINEMERGE = false


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

4 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:
      rtsp://(user):(password)@(ipaddress):554/cam1/onvif-h264-1

      Sub-Video Feed:
      http://(user):(password)@(ipaddress)/Streaming/channels/102/httppreview

  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

    • 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.

Leave a Reply

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