Git Product home page Git Product logo

pageauc / speed-camera Goto Github PK

View Code? Open in Web Editor NEW
950.0 48.0 168.0 4.74 MB

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.

License: Apache License 2.0

Python 89.90% Shell 9.86% Dockerfile 0.25%
motion-tracking opencv rpi-camera speed-cam raspberry-pi-computer vehicle road moving traffic video-streaming

speed-camera's Introduction

SPEED CAMERA - Object Motion Tracker Mentioned in Awesome <INSERT LIST NAME>

RPI, Unix and Windows Speed Camera Using python, openCV, RPI camera module, USB Cam or IP Cam

Note re Bullseye:

Speed-cam.py ver 11.26 and greater will now run under Raspberry Pi OS Bullseye or later with a pi camera module as well as usbcam and IP/RTSP cameras. For picamera support Run sudo raspi-config, Interface Options, then enable/disable Legacy Camera option and reboot.

RPI Quick curl Install or Upgrade

IMPORTANT - A raspbian sudo apt-get update and sudo apt-get upgrade will NOT be performed as part of
speed-install.sh so it is highly recommended you run these prior to install to ensure your system is up-to-date.

Step 1

Press GitHub copy icon on right side of code box below.
or With mouse left button highlight curl command in code box below. Right click mouse in highlighted area and select Copy.

curl -L https://raw.github.com/pageauc/speed-camera/master/speed-install.sh | bash

Step 2

On RPI putty SSH or terminal session right click, select paste then Enter to download and run script.

This will download and run the speed-install.sh script. If running under python3 you will need opencv3 installed if not installed. If you need to compile openCV see my Github Repo at menu driven compile opencv3 from source project

Ver 13.00 Notes

Version 13.05 is a major speed camera revision. Camera thread code is now handled by a strmcam.py module. config.py variable names have changed so you will need to backup and cp config.py.new config.py (see below for details)
IMPORTANT : All settings are in config.py. You can delete configcam.py if it exists, once you upgrade to ver 13.05 or greater. plugins now work. You can customize plugin files to suit you needs or create your own. If you are upgrading you should delete, move old plugins so new ones will be downloaded during UPGRADE. Please post GitHub issue if you find a bug or problem. Claude

IMPORTANT speed-cam.py ver 8.x or greater Requires Updated config.py and plugins.

cd ~/speed-camera
cp config.py config.py.bak
cp config.py.new config.py

To replace plugins rename (or delete) plugins folder per below

cd ~/speed-camera
mv plugins pluginsold   # renames plugins folder
rm -r plugins           # deletes plugins folder

Then run menubox.sh UPGRADE menu pick.

Mac or Windows Systems

See Windows 10/11 or Apple Mac Docker Install Quick Start
or Windows or Unix Distro Installs without Docker

Program Description

This is a raspberry pi, Windows, Unix Distro computer openCV object speed camera demo program. It is written in python and uses openCV to detect and track the x,y coordinates of the largest moving object in the camera view above a minimum pixel area.

User variables are stored in the config.py file. Motion detection is restricted between MO_CROP_Y_UPPER, MO_CROP_Y_LOWER, MO_CROP_X_LEFT, MO_CROP_X_RIGHT variables (road or area of interest). MO_CROP_AUTO_ON = True overrides manual settings and will Auto calculate a rough crop area based on image size. Motion Tracking is controlled by the MO_TRACK_EVENT_COUNT variable in config.py. This sets the number of track events and the track length in pixels. This may need to be tuned for camera view, cpu speed, etc. Speed is calculated based on CAL_OBJ_PX_ and CAL_OBJ_MM_ variables for L2R and R2L motion direction. A video stream frame image will be captured and saved in media/images dated subfolders (optional) per variable IM_SUBDIR_MAX_FILES = 2000 For variable settings details see config.py file.

If LOG_DATA_TO_CSV = True then a speed-cam.csv file will be created/updated with event data stored in CSV (Comma Separated Values) format. This can be imported into a spreadsheet, database, Etc program for further processing. Release 8.9 adds a sqlite3 database to store speed data. Default is data/speed_cam.db with data in the speed table. Database setting can be managed from config.py. Database is automatically created from config.py settings. For more details see How to Manage Sqlite3 Database

Admin, Reports, Graphs and Utilities scripts

  • menubox.sh script is a whiptail menu system to allow easier management of program settings and operation.
  • run.sh This bash script uses supervisorctl to manage start, stop, status of speed-cam.py and webserver.py. Configured to autostart eg due to interruption of RTSP stream. See conf files in supervisor folder for details. Note: you must run ./run.sh install to initialize symbolic links to /etc/supervisor/conf.d folder. Stop running any speed-cam and/or websever processes before running ./run.sh start
  • webserver.py Allows viewing images and/or data from a web browser (see config.py for webserver settings)
  • rclone Manage settings and setup for optional remote file sync to a remote storage service like google drive, DropBox and many others.
  • watch-app.sh for administration of settings from a remote storage service. Plus application monitoring.
  • sql-make-graph-count-totals.py Query sqlite database and Generate one or more matplotlib graph images and save to media/graphs folder. Graphs display counts by hour, day or month for specfied previous days and speed over. Multiple reports can be managed from the config.py GRAPH_RUN_LIST variable under matplotlib image settings section.
  • sql-make-graph-speed-ave.py Query sqlite database and Generate one or more matplotlib graph images and save to media/graphs folder. Graphs display Average Speed by hour, day or month for specfied previous days and speed over. Multiple reports can be managed from the config.py GRAPH_RUN_LIST variable under matplotlib image settings section.
  • sql-speed_gt.py Query sqlite database and Generate html formatted report with links to images and save to media/reports folder. Can accept parameters or will prompt user if run from console with no parameters
  • makehtml.py Creates html files that combine csv and image data for easier viewing from a web browser and saved to media/html folder.
  • speed-search.py allows searching for similar target object images using opencv template matching. Results save to media/search folder.
  • alpr-speed.py This is a demo that processes existing speed camera images with a front or back view of vehicle using OPENALPR License plate reader. Output is saved to media/alpr folder. For installation, Settings and Run details see ALPR Wiki Documentaion

Reference Links

Requirements

Raspberry Pi computer and a RPI camera module installed or USB Camera plugged in. Make sure hardware is tested and works. Most RPI models will work OK. A quad core RPI will greatly improve performance due to threading. A recent version of Raspbian operating system is Recommended.
or
MS Windows or Unix distro computer with a USB Web Camera plugged in and a recent version of python installed For Details See Wiki details.

It is recommended you upgrade to OpenCV version 3.x.x For Easy compile of opencv 3.4.2 from source See https://github.com/pageauc/opencv3-setup

Windows or Non RPI Unix Installs

For Windows or Unix computer platforms (non RPI or Debian) ensure you have the most up-to-date python version. For Download and Install python and Opencv

The latest python versions includes numpy and recent opencv version that is required to run this code. You will also need a USB web cam installed and working. To install this program access the GitHub project page at https://github.com/pageauc/speed-camera Select the green Clone or download button. The files will be cloned or zipped to a speed-camera folder. You can run the code from python IDLE application (recommended), GUI desktop or command prompt terminal window. Note bash .sh shell scripts will not work with windows unless special support for bash is installed for windows Eg http://win-bash.sourceforge.net/ http://www.cygwin.com/ Note: I have Not tested these.

Docker Install Quick Start

speed camera supports a docker installation on
Apple Macintosh per System requirements and Instructions
and
Microsoft Windows 10/11 64 bit with BIOS Virtualization enabled and Microsoft Windows Subsystem for Linux WSL 2 per System requirements and Instructions.

  1. Download and install Docker Desktop for your System
  2. Clone the GitHub Speed Camera repository using green Clone button (top right)
  3. Run docker-compose up from the directory you cloned the repo into.
  4. The Docker container will likely exit because it is using a default config.
  5. Edit the configuration file @ config/config.py
  6. Run docker-compose up per documentation
  7. Run docker build command locally to get a fresh image.

Raspberry pi Manual Install or Upgrade

From logged in RPI SSH session or console terminal perform the following. Allows you to review install code before running

cd ~
wget https://raw.github.com/pageauc/speed-camera/master/speed-install.sh
more speed-install.sh       # You can review code if you wish
chmod +x speed-install.sh
./speed-install.sh  # runs install script.

Run to view verbose logging

cd ~/speed-camera    
./speed-cam.py

See How to Run speed-cam.py wiki section

IMPORTANT Speed Camera will start in CALIBRATE_ON = True Mode.
Review settings in config.py file and edit variables with nano as required. You will need to perform a calibration to set the correct value for config.py CAL_OBJ_PX_ and CAL_OBJ_MM_ for L2R and R2L directions. The variables are based on the distance from camera to objects being measured for speed. See Calibration Procedure for more details.

The config.py motion tracking variable called track_counter = can be adjusted for your system and opencv version. Default is 5 but a quad core RPI3 and latest opencv version eg 3.4.2 can be 10-15 or possibly greater. This will require monitoring the verbose log messages in order to fine tune.

Run menubox.sh

cd ~/speed-camera
./menubox.sh

Admin speed-cam Easier using menubox.sh (Once calibrated and/or testing complete)
menubox main menu

View speed-cam data and trends from web browser per sample screen shots. These can be generated from Menubox.sh menu pick or by running scripts from console or via crontab schedule.

Speed Camera GRAPHS Folder Web Page
Speed Camera REPORTS Folder Web Page
Speed Camera HTML Folder Web Page

You can view recent or historical images directly from the speed web browser page. These are dynamically created and show up-to-date images. Press the web page refresh button to update display Speed Camera RECENT Folder Web Page
Speed Camera IMAGES Folder Web Page

Credits

Some of this code is based on a YouTube tutorial by Kyle Hounslow using C here https://www.youtube.com/watch?v=X6rPdRZzgjg

Thanks to Adrian Rosebrock jrosebr1 at http://www.pyimagesearch.com for the PiVideoStream Class code available on github at https://github.com/jrosebr1/imutils/blob/master/imutils/video/pivideostream.py

Have Fun
Claude Pageau
YouTube Channel https://www.youtube.com/user/pageaucp
GitHub Repo https://github.com/pageauc

speed-camera's People

Contributors

anthonymobile avatar balsama avatar dericke avatar fadkeabhi avatar ianmaciel avatar jeremybmerrill avatar pageauc avatar randallkent avatar slutsteg avatar stollthbel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

speed-camera's Issues

[Questions] Various

Hi Claude, awesome project thanks!

From what I gather, your project requires the distance from the camera to the points it is getting the coordinates from. Would it not be possible to measure two points on the road and just make sure the program's points where it checks are lined up to those? Maybe putting a two little flags in the ground, measuring the distance, then making sure those flags line up to the detection points in the program? Or is this too naive from a math point of view?

Next question - do you think it would be a big job to make this project be able to recognise number (license) plates too? Obviously you'd have to be at the correct angle to be able to view them and potentially have to run at a higher resolution. Any pointers on what are of OpenCV might be able to achieve this?

Finally, for my curiosity ;) Did you have any experience in image processing before starting with OpenCV? How did you find the learning curve? I'm primarily a web based programmer but have a good decade programming experience so wondering whether there any background reading/studying you can suggest before diving in head first!

Thanks again, looking forward to giving this a try.

AttributeError: 'NoneType' object has no attribute 'shape'

I downloaded the programs by using the curl method. And then I ran the speed-cam.py program by using the ./speed-cam.py. But the program gave me the error:AttributeError: 'NoneType' object has no attribute 'shape' Segmentation fault

I don't know how to solve this issue. I even reinstalled everything(including the os) on the raspberry pi. I still had the same error. It would be great if someone could help me.

I have attached a picture of the error I keep getting:
AttributeError

How to use ip cam?

Hi, your code is awesome, I've tried this code,but I want to use my IP cam, how to use ip cam with this code?
Thanks

findContours() error since recent change

Since the recent changes (mentioning newer opencv which raspbian doesn't have?), speed-cam.py fails with:

Traceback (most recent call last):
  File "speed-cam.py", line 521, in <module>
    speed_camera()
  File "speed-cam.py", line 395, in speed_camera
    thresholdimage, contours, hierarchy = cv2.findContours( thresholdimage,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE )
ValueError: need more than 2 values to unpack

Rolling back the changes in this area, made in cfa677e , works around the problem.

Very inacurrate - but not linear...

Hi,

I set up your tool a couple of days ago and I am still wondering how to get at least "linear" inaccurate measurements.
I am about 10 meters away from the road in approx 4 m height.
After using the calibration mode I entered the numbers in the config file and started it again.
The first car was measured with about 20 kph, which could be right.... after that another car (don't know how fast it really was, but 284 kph can not be achieved on my road, nor with a 1 litre Ford Fiesta...
After that a couple of around 20 kph but several 50 kph cars were catched -
After that I drove myself in front of the camera with GPS 20 kph and the cam got 54 kph...

Maybe I do not understand the calibration process, but even if I don't...why isn't the error at least linear?

BTW: I am using a Raspberry Pi 3 Quadcore , picam720 and a wide angle lens (but the red calibration box is only in the middle, were the distortion is not very big.

Thanks alot for your help.

Cheers
4920441

[Questions] Raspberry Pi 3 + V2 Camera

Hi Claude,

Thanks for putting together such a great project!

I'm trying to squeeze every last bit of performance out of my Raspberry Pi 3, and have hit a wall at around 26fps with a resolution of 912 x 400.

Do you have any suggestions for improving my framerate at this resolution?
Also, what effect does resolution vs framerate have on the overall accuracy of the speed-cam readings?
Finally, do you plan on releasing an updated version with the new OpenCV3.x?

Thanks again for your great work.

Release 8.4 now has faster event timeouts and x_diff settings to ignore out of range values

I have been working on making the code more pythonic but variable naming still needs work. Release 8.4 now has reduced tracking timeout value of 0.3 sec. Also the reduced x_diff_max value is reduced to only track movement if next x position does not exceed the x_diff_max px distance away from current x position otherwise an out of range logging message is displayed.

I recommend you delete or rename previous speed-camera directory and do a fresh curl install if possible. You can also upgrade plugin folder and use the new config.py per commands below

cd ~/speed-camera
mv plugins pluginsold
mv config.py config.py.old
curl -L https://raw.github.com/pageauc/speed-camera/master/speed-install.sh | bash

See wiki for details

Let me know if this works better for you.
Claude ...

Elasticsearch Integration

Hi Claude,

Great work with this package. We in the village of Chailey, UK want to monitor the amount and speed of traffic on the A275. The road is a major trunk road, but single-lane, and 40mph for most of the village. https://www.google.com/maps/place/50ยฐ56'18.7"N+0ยฐ01'18.8"W

The plan is to have multiple raspberry pi's with your software on running. We then would like to merge the data and display it. I happen to work for elastic.co, so have been playing around on my ElasticStack lab at home. I've put this simple graph-set together by using logstash to read the csv file, and import into elasticsearch. I am having to run logstash on a separate server and xfer the csv file there first at the moment. The fingerprint part gives each detection a unique stamp to avoid duplicates.

For reference, here is the logstash config:

input {
  file {
    path => "/speed-camera/speed-cam.csv"
    sincedb_path => "/tmp/csv.db"
    start_position => "beginning"
  }
}
filter {
  csv {
     separator => ","
     columns => ["Date","Hour","Minute","Speed","Unit","Image","X","Y","W","H","Area","Direction"]
  }
  fingerprint {
          source => "message"
          target => "[@metadata][fingerprint]"
          method => "SHA1"
          key => "ChaileySpeed"
          base64encode => true
  }
  mutate {
          add_field => [ "timestamp","%{Date}%{Hour}:%{Minute}" ]
          remove_field => ["Hour","Minute"]
          remove_field => ["message"]
  }
  mutate {
          convert => { "Speed" => "float" }
  }

  date {
          match => ["timestamp","yyyyMMddHH:mm"]
          target => "Date"
  }
  alter {
          condrewrite => [
                  "Direction","L2R", "Southbound",
                  "Direction","R2L", "Northbound"
          ]
  }
}
output {
  elasticsearch {
    hosts => [ "https://my-host:9243" ]
    cacert => "/etc/logstash/certs/ca.crt"
    user => "redacted"
    password => "redacted"
    index => "speedcam-%{+YYYY.MM.dd}"
    document_id => "%{[@metadata][fingerprint]}"
  }
  #stdout {codec => "rubydebug"}
}

Here is the dashboard from kibana:
Screenshot_2019-06-26 SpeedCamera Dashboard - Kibana

I'd like to make it so that the speedcamera program makes a direct REST call to elasticsearch. Is that something you could help with? The REST API call is pretty simple - see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

I would also like to see the ability to calculate speeds differently depending on direction too if possible.

How can I help?

Cheers,

Richie

Not able to detect vehicles if i use rectangle instead of show_circle

Hello Sir,
I changed show_circle = false in config.py for using rectangle instead of circle, so using rectangle not able detect or capture images of vehicles. please help me for solving this issue. I have assigned max_speed_over= 20 in config.py, therfore it should capture vehicle images if vehicle speed is greater than 20, when i use show_circle = true , its able to capture images, but when i use rectangle not able to capture the images.

speed

Hi sir i saw this question #41 (comment) im interested to know its possible to change angle of view and fps to detect the real speed of the object .

Error After Recent Update

Received new error running in calibration mode:

2018-07-01 19:31:34 INFO speed_camera Saved media/images/calib-20180701-193134.jpg
Traceback (most recent call last):
File "./speed-cam.py", line 1304, in
speed_camera() # run main speed camera processing loop
File "./speed-cam.py", line 1085, in speed_camera
(log_time.year,
UnboundLocalError: local variable 'log_time' referenced before assignment

Happens every time on the second track.

Distance from road

Really looking forward to setting this up - one question though if I may: in the wiki it says:

Please note that if road is too close and/or vehicles are moving too quickly then the camera may not capture motion and/or record vehicle in speed photo.

Do you have any further details on how far away from the road the camera needs to be to get a reliable detection? I'll struggle to get it much further away than 10 meters unfortunately. Another option I thought of might be a fish eye lens, although I guess that might confuse the image processing.

integrating timeseries database with speedcam app

Hello Claude,

I did tried to integrate influxdb logging through using example from here: https://github.com/influxdata/influxdb-python (check on bottom of the page)

Pretty sure that my programming skills are not yet there, so I did something wrong.

Here is how I did connected:

from influxdb import InfluxDBClient
client = InfluxDBClient('10.0.1.181', 8086, '', '', 'speedcamdb')
client.create_database('speedcamdb')

Then, just before you insert sqlite3 database table, I wrote this one:

speed_data_influx_json = [{
                                  "log_idx": log_idx,
                                  "log_date": log_date,
                                  "log_hour": log_hour, 
                                  "log_minute": log_minute,
                                  "camera": camera,
                                  "ave_speed": ave_speed, 
                                  "speed_units": speed_units, 
                                  "filename": filename,
                                  "image_width": image_width, 
                                  "image_height": image_height, 
                                  "image_bigger": image_bigger,
                                  "travel_direction": travel_direction, 
                                  "plugin_name": plugin_name, 
                                  "track_x": track_x, 
                                  "track_y": track_y,
                                  "track_w": track_w, 
                                  "track_h": track_h, 
                                  "m_area": m_area, 
                                  "x_left": x_left, 
                                  "x_right": x_right,
                                  "y_upper": y_upper, 
                                  "y_lower": y_lower,
                                  "max_speed_over": max_speed_over,
                                  "min_area": MIN_AREA, 
                                  "track_counter": track_counter,
                                  "cal_obj_px": cal_obj_px, 
                                  "cal_obj_mm": cal_obj_mm
                                }]

Then after the sqlite3 tried to write measurements to influxdb, with:
client.write_points(speed_data_influx_json)

But unsuccessful. I get:

2020-01-03 14:54:52 INFO     db_check   Success: sqlite3 Connected to DB /home/pi/speed-camera/data/speed_cam.db
Traceback (most recent call last):
  File "./speed-cam.py", line 1661, in <module>
    speed_camera() # run main speed camera processing loop
  File "./speed-cam.py", line 1407, in speed_camera
    client.write_points(speed_data_influx_json)
  File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 530, in write_points
    consistency=consistency)
  File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 598, in _write_points
    protocol=protocol
  File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 331, in write
    data = make_lines(data, precision).encode('utf-8')
  File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 156, in make_lines
    for field_key, field_value in sorted(iteritems(point['fields'])):
KeyError: u'fields'

I'll keep investigating the code and influxdb puthon integration documentation.

Thank you for a great piece of software. I would really like to make it work with influxdb and grafana so I can make better visual for local neighborhood and maybe even for local authorities if they are interested in speeding drivers and statistics.

Respectfully,
DV

After Application Crash Unable to connect to USB Camera on Windows

After the application crashes with the following error:

Traceback (most recent call last):
File "C:\Users*\Downloads\speed-camera-master\speed-cam.py", line 1084, in
speed_camera() # run main speed camera processing loop
File "C:\Users*
\Downloads\speed-camera-master\speed-cam.py", line 763, in speed_camera
image_crop = image2[y_upper:y_lower, x_left:x_right]
TypeError: 'NoneType' object has no attribute 'getitem'

The application does not detect the USB camera and I receive the following error. Only a machine reboot will resolve the issue.

2018-03-26 08:36:14 INFO Initializing USB Web Camera Try .. 1
2018-03-26 08:36:18 WARNING speed_camera Problem Connecting To Camera Stream.
2018-03-26 08:36:18 WARNING speed_camera Restarting Camera. One Moment Please ...
2018-03-26 08:36:22 INFO Initializing USB Web Camera Try .. 2
2018-03-26 08:36:26 WARNING speed_camera Problem Connecting To Camera Stream.
2018-03-26 08:36:26 WARNING speed_camera Restarting Camera. One Moment Please ...
2018-03-26 08:36:30 INFO Initializing USB Web Camera Try .. 3
2018-03-26 08:36:34 WARNING speed_camera Problem Connecting To Camera Stream.
2018-03-26 08:36:34 WARNING speed_camera Restarting Camera. One Moment Please ...
2018-03-26 08:36:38 INFO Initializing USB Web Camera Try .. 4
2018-03-26 08:36:38 ERROR USB Web Cam Not Connecting to WEBCAM_SRC 0
2018-03-26 08:36:38 ERROR Check Camera is Plugged In and Working
2018-03-26 08:36:38 ERROR on Specified SRC
2018-03-26 08:36:38 ERROR and Not Used(busy) by Another Process.
2018-03-26 08:36:38 ERROR speed-cam.py 8.6 Exiting Due to Error

Hash Marks Off Center

The hash marks are off-center from the calibration image. Do you know how I can adjust those so it would be easier to capture my image? They appear fine when using the pi camera but when using a USB webcam they are misaligned. I had a rather difficult time fine tuning the calibration of the pi camera and difficulty mounting the pi in the window so I went with USB camera instead. See image link for hash mark example. https://imgur.com/a/rRLUbFY

the fps influence the speed ?

the fps influence the speed ?, Why the fps change sometimes varies by light or speed or other factors, is not always constant.

not save images, version 6.9

How do I just capture and save the object that follows,?, And not the entire image of the camera

ย  Does it support multiple movement objects?

Release 8.9 of Speed Camera implements a sqlite3 speed data table

I have implemented speed camera data storage into a sqlite3 database speed table. Default to log data to csv is left enabled but this can be disabled in config.py
There is a short report script that allows selecting by speed greater than specified value.

./sql_speed_gt.sh

I will be looking at the data structure. Take a look at the speed-cam.py code for details
I am hoping to set up a web page interface to run queries.

Default database location is /home/pi/speed-camera/data/speed_cam.db table is named speed. You can look at the table by connecting through sqlite3 command console on raspberry pi (it is installed by default)

At the sqlite console prompt here are some sample commands or use .help to get list of sqlite3 console dot commands. You can also execute sql commands. Note sql commands must end with a semi colon ;

cd ~/speed-camera
sqlite3 data/speed_cam.db
.tables
.schema
select * from speed;
select speed_ave, speed_units, image_path, direction from speed where speed_ave > 40;
.exit

Also take a look at sample query bash script sql_speed_gt.sh

more sql_speed_gt.sh

Regards Claude ...

get GUI working

I am having some issues getting the GUI working on my Raspi2.

Settings -------------------------------------

Plugins ......... pluginEnable=False pluginName=picam480
Message Display . verbose=True display_fps=False calibrate=True
show_out_range=True
Logging ......... Log_data_to_CSV=True log_filename=speed-cam.csv (CSV format)
loggingToFile=True logFilePath=speed-cam.log
Log if max_speed_over > 1 mph
Speed Trigger ... If track_len_trig > 75 px
Exclude Events .. If x_diff_min < 1 or x_diff_max > 15 px
If y_upper < 140 or y_lower > 340 px
or x_left < 150 or x_right > 490 px
If max_speed_over < 1 mph
If event_timeout > 0 seconds Start New Track
track_timeout=0 sec wait after Track Ends (avoid retrack of same object)
Speed Photo ..... Size=960x720 px image_bigger=1 rotation=180 VFlip=True HFlip=True
image_path=media/images image_Prefix=speed-
image_font_size=22 px high image_text_bottom=False
Motion Settings . Size=640x480 px px_to_kph=0.086600 speed_units=mph
OpenCV Settings . MIN_AREA=200 sq-px BLUR_SIZE=10 THRESHOLD_SENSITIVITY=20 CIRCLE_SIZE=4 px
WINDOW_BIGGER=1 gui_window_on=True (Display OpenCV Status Windows on GUI Desktop)
CAMERA_FRAMERATE=25 fps video stream speed
Sub-Directories . imageSubDirMaxHours=0 (0=off) imageSubDirMaxFiles=1000 (0=off)
imageRecentDir=media/recent imageRecentMax=100 (0=off)
Disk Space ..... Enabled - Manage Target Free Disk Space. Delete Oldest jpg Files if Needed
Check Every spaceTimerHrs=24 hr(s) (0=off) Target spaceFreeMB=500 MB min is 100 MB)
If Needed Delete Oldest spaceFileExt=jpg spaceMediaDir=media/images


(Movement (q Quits):1481): Gtk-WARNING **: cannot open display:

image zoom/cropped when using higher fps

When upping the FPS beyond 40, it seems this causes the tracking and photo to be zoomed in and/or cropped, so you end up with a heavily pixelated version at a much lower resolution, but still with the motion area indicated (though it's way off where it should be, as you're zoomed in about 2x, viewing just a box in the centre of the expected view area).

Updated Install guidance

I'm having some troubles with motion tracking performance using a Pi 3B+ and latest version of Raspian Buster. Even at meager performance settings of only 240 pixels (30FPS, with 5 required tracks) I have vehicles scooting through my motion tracking widow without being photoed. I even tried reducing the motion tracking window to approx 30% of the full camera area.

I'm trying to determine if its a software issue, or if its time for an upgrade to a Pi4. Most of the install steps for the speed-camera are for Pi3 or older with Jesse. I'm wondering if there are adjusted install steps for Buster and/or Pi4? Is the manual build of OpenCV still required? SO far, I've been running a current Buster image with "apt update" and "apt full-upgrade", but no other package customization.

Any suggestions for setup from scratch on newer hardware/software would be appreciated.

Not tracking events

Hi,
I'm using a rpi3 and going through the inital setup. Install went great. I'm going through the calibration process and I'm not able to trigger/record a motion tracking event.

  • I start the speed-cam.py and webserver.py (calibration =true)
  • I log into my rpi thorough my desptop via the IP:8080. The SPEED-CAMERA Media page loads, but nothing is captured when I try to trigger an event. If I check the links on the right they are empty (except for the txt under webserver.txt).
  • Manually checked the speed-cam media folders and they are empty.

What I've tested:

  • I've tested the pi-camera and it is working correctly.
  • I've enabled gui_window to display the OpenCV video window and that displays video with the motion area and moving tracking box as expected.
  • Log_data_to_CVS is set to True.
  • If I kill the processes and run speed-cam.py from terminal, it initiates the tracking and displays it to the screen.

If you need any additional information, let me know,

Thanks!!

Show camera

Hi sir , i hope you are doing well ,
firstly i want to thank you so much for your great project, it's very helpful.
so i run your program its work well but the display of the camera does not show , then i change the variables gui_windows=True and i find the some issue--> i cant see the display of my camera. please sir i need your help.

Outstanding!

Brilliant, innovative program. Thanks for sharing your thoughtful ideas. I've learned a great deal from your projects.

It would be great to distinguish direction of motion, logging to csv file - analyze data by direction (uphill vs downhill in my case). I'll work on that as soon as I understand your code more thoroughly. I'm new to openCV.

Thanks!
Carter Cherry, appreciative follower of your work
Morgan Hill, CA

New bug :(

Hi Claude,

I've not investigated yet, but I note you are in the process of changing the time format. Well, it breaks it :(

I've roll my Production instances to the previous version, but wanted to let you know ASAP, so sorry for the 'raw' bug report.

Cheers,

Richie

Loading ...
----------------------------------------------------------------------
speed-cam.py 9.21   written by Claude Pageau
2019-07-02 16:54:32 INFO     <module>   Pi Camera Module is Enabled and Connected supported=1 detected=1
----------------------------------------------------------------------
Note: To Send Full Output to File Use command
python -u ./speed-cam.py | tee -a log.txt
Set log_data_to_file=True to Send speed_Data to CSV File speed-cam.log
----------------------------------------------------------------------

Debug Messages .. verbose=True  display_fps=False calibrate=False
                  show_out_range=True
Plugins ......... pluginEnable=False  pluginName=picam240
Calibration ..... cal_obj_px_L2R=60 px  cal_obj_mm_L2R=5182 mm  speed_conv_L2R=0.19320
                  cal_obj_px_R2L=75 px  cal_obj_mm_R2L=5182 mm  speed_conv_R2L=0.15456
                  (Change Settings in /home/pi/speed-camera/config.py)
Logging ......... Log_data_to_CSV=True  log_filename=speed-cam.csv (CSV format)
                  loggingToFile=False  logFilePath=speed-cam.log
                  SQLITE3 DB_PATH=/home/pi/speed-camera/data/speed_cam.db  DB_TABLE=speed
Speed Trigger ... Log only if max_speed_over > 0 mph
                  and track_counter >= 5 consecutive motion events
Exclude Events .. If  x_diff_min < 1 or x_diff_max > 20 px
                  If  y_upper < 75 or y_lower > 185 px
                  or  x_left < 5 or x_right > 315 px
                  If  max_speed_over < 0 mph
                  If  event_timeout > 0.30 seconds Start New Track
                  track_timeout=0.00 sec wait after Track Ends (avoid retrack of same object)
Speed Photo ..... Size=960x720 px  image_bigger=3.0  rotation=0  VFlip=False  HFlip=False
                  image_path=media/images  image_Prefix=speed-
                  image_font_size=12 px high  image_text_bottom=True
Motion Settings . Size=320x240 px  px_to_kph_L2R=0.310920  px_to_kph_R2L=0.248736 speed_units=mph
OpenCV Settings . MIN_AREA=100 sq-px  BLUR_SIZE=10  THRESHOLD_SENSITIVITY=20  CIRCLE_SIZE=5 px
                  WINDOW_BIGGER=1 gui_window_on=False (Display OpenCV Status Windows on GUI Desktop)
                  CAMERA_FRAMERATE=20 fps video stream speed
Sub-Directories . imageSubDirMaxHours=1 (0=off)  imageSubDirMaxFiles=1000 (0=off)
                  imageRecentDir=media/recent imageRecentMax=0 (0=off)
Disk Space  ..... Disabled - spaceTimerHrs=0  Manage Target Free Disk Space. Delete Oldest jpg Files
                  spaceTimerHrs=0 (0=Off) Target spaceFreeMB=500 (min=100 MB)

----------------------------------------------------------------------
2019-07-02 16:54:32 INFO     <module>   Initializing Pi Camera ....
2019-07-02 16:54:35 INFO     isSQLite3  Success: File is sqlite3 Format /home/pi/speed-camera/data/speed_cam.db
2019-07-02 16:54:35 INFO     db_check   Success: sqlite3 Connected to DB /home/pi/speed-camera/data/speed_cam.db
2019-07-02 16:54:35 INFO     speed_camera sqlite3 DB is Open /home/pi/speed-camera/data/speed_cam.db
2019-07-02 16:54:35 INFO     speed_notify Plugin Disabled per pluginEnable=False
2019-07-02 16:54:35 INFO     speed_notify Logging to Console per Variable verbose=True
2019-07-02 16:54:35 INFO     speed_notify Press ctrl-c in this terminal session to Quit
2019-07-02 16:54:35 INFO     speed_notify Begin Motion Tracking .....
2019-07-02 16:54:36 INFO     speed_camera Reset- event_timer 0.94>0.30 sec Exceeded
2019-07-02 16:54:36 INFO     speed_camera New  - 0/5 xy(40,29) Start New Track
2019-07-02 16:54:36 INFO     speed_camera  Add - 1/5 xy(50,30) 50.91 mph D=10/20 C=1 65x26=1081 sqpx L2R
2019-07-02 16:54:36 INFO     speed_camera  Add - 2/5 xy(62,33) 30.91 mph D=12/20 C=1 63x23=999 sqpx L2R
2019-07-02 16:54:36 INFO     speed_camera  Add - 3/5 xy(73,32) 62.54 mph D=11/20 C=1 62x25=1001 sqpx L2R
2019-07-02 16:54:36 INFO     speed_camera  Add - 4/5 xy(84,33) 31.28 mph D=11/20 C=1 61x24=966 sqpx L2R
2019-07-02 16:54:36 INFO     speed_camera  Add - 5/5 xy(94,33) 53.28 mph D=10/20 C=1 61x24=959 sqpx L2R
Traceback (most recent call last):
  File "./speed-cam.py", line 1467, in <module>
    speed_camera() # run main speed camera processing loop
  File "./speed-cam.py", line 1160, in speed_camera
    image_path, image_prefix)
  File "./speed-cam.py", line 700, in subDirChecks
    if subDirCheckMaxHrs(subDirPath, maxHours, prefix):
  File "./speed-cam.py", line 669, in subDirCheckMaxHrs
    dirDate = datetime.datetime.strptime(dirStr, "%Y-%m-%d-%H:%M")
  File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
    (data_string, format))
ValueError: time data '20190702-1643' does not match format '%Y-%m-%d-%H:%M'

Struggled to get this working

On a raspberry pi 3 b+ 240p configuration with Pi Cam v2 placed 80' from edge of road with a 145x30 crop window, was having issues with cv2 exceeding x_diff_max=45 with speeds exceeding 30Mph.

After following this tutorial I am seeing substantially better performance: https://www.pyimagesearch.com/2017/10/09/optimizing-opencv-on-the-raspberry-pi/

BTW raspberry pi 0w really was a dog... Might want to mention it is a real non starter...

I still need to do some tuning but will provide more details once I get it fine tuned.

speed-cam.py release 3.6 Added logic for html folder and images sym link

This is an updated release to add auto creating of the html folder and an associated sym link that points to the images folder. This is required for the webserver root to work properly. You will need at least three entries in the csv file before running makehtml.py but otherwise this release seems to do the job since I had to accommodate varying paths for the images folder and the html folder locations. This will auto create all folder when path contains multiple folders. Let me know if you have issues.

Recently added menubox.sh release 5.7 Adds target file file browser for search file selection

I have updated menubox.sh to ver 5.7 and added a menu driven file browser to select target search images. I developed a file browser to make copying target files to media/search easier. Use webserver and a web browser to look at the target search files you are interested in then use menubox.sh to setup and run the target searches. The results can be viewed with a web browser by navigating to media/search and selecting the appropriate sub folder. See the about boxes for more information.

Claude ....

VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV

Dear Sir,

Have been trying to get your amazing project up and running on a Nvidea Jetson Nano, combined with a RPi Cam v2 (supported out of the box).

When trying to run the speed-cam.py I get the VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV.

So have been researching the error.

Things I have checked:

v4l2-ctl -d /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'RG10'
Name : 10-bit Bayer RGRG/GBGB

When testing the camera with GStreamer the camera is working correctly (appears under /dev/video0;

(Source: https://www.jetsonhacks.com/2019/04/02/jetson-nano-raspberry-pi-camera/)
gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12' ! nvvidconv flip-method=0 ! 'video/x-raw,width=960, height=616' ! nvvidconv ! nvegltransform ! nveglglessink -e

So it appears that most probably I will have to build OpenCV with Gstreamer enabled:
(Source: https://devtalk.nvidia.com/default/topic/1001696/jetson-tx1/failed-to-open-tx1-on-board-camera/post/5117370/#5117370)

But then the question is do you consider supporting GStreamer Pipeline in your application?

Kind regards

Koen

How can be calculate the speed

Hello Mr. Pageeac
Thank you for sharing your Great project .My end of study project topic, is almost the same project like you did, it's about the vehicle speed detection at real time using Camera IP in a highway , I took a look in your code , I can't understand how you calculate the speed ,and how can you know the real distance from ( fps and distance between the camera and object ) ?
Also i see you calculated the speed from L2R or R2L . It's possible to calculate the speed from front to behind F2B and from behind to front B2F?

vehicles not detected - timeout exceeded

Hi,

I don't get it. Everything looks working correctly but the vehicles looks not being detected.

The logs says most of the time something like this :

2019-10-19 14:54:34 INFO     speed_notify Begin Motion Tracking .....
2019-10-19 15:02:30 INFO     speed_camera Reset- event_timer 476.63>0.60 sec Exceeded
2019-10-19 15:02:30 INFO     speed_camera New  - 0/10 xy(70,45) Start New Track
2019-10-19 15:04:19 INFO     speed_camera Reset- event_timer 109.05>0.60 sec Exceeded
2019-10-19 15:04:19 INFO     speed_camera New  - 0/10 xy(74,37) Start New Track
2019-10-19 15:07:27 INFO     speed_camera Reset- event_timer 187.96>0.60 sec Exceeded
2019-10-19 15:07:27 INFO     speed_camera New  - 0/10 xy(62,43) Start New Track
2019-10-19 15:07:28 INFO     speed_camera Reset- event_timer 0.70>0.60 sec Exceeded
2019-10-19 15:07:28 INFO     speed_camera New  - 0/10 xy(63,43) Start New Track

The only time I saw the system actually measuring something was when a pedestrian passed in the field ๐Ÿ˜‚

This is the picture I'm capturing. NB : Cars displayed are parked.

image

What should I do ? Am I too close ?

Txs

Matthieu

Please help

Hi Claude

Thanks for this project, although ive been pulling my hair out all day

Fron GUI when i run
pi@raspberrypi:~/speed-camera $ ./speed-cam.py

I get this following Error

Loading ...

speed-cam.py 9.4 written by Claude Pageau

Traceback (most recent call last):
File "./speed-cam.py", line 216, in
if not os.path.exists(DB_DIR): # Check if database directory exists
File "/usr/lib/python2.7/genericpath.py", line 26, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, tuple found
pi@raspberrypi:~/speed-camera $

I have the following Dir
/home/pi/speed-camera/data/speed_cam.db
i also added
/home/pi/speed-camera/database
not sure if it should be there but i seen ref to it i think will ive been looking through code

Any help would be greatly appreciated

Thank You
Jason

Analysing larger images?

When using a pi camera v2 with a higher resolution, would it aid accuracy to be processing higher resolution images, and if so how is this achieved?

Changing CAMERA_WIDTH and CAMERA_HEIGHT seems to only zoom in, creating a larger output image but blurred/pixelated version with heavy cropping of all sides.

Cannot change SPEED_MPH to MPH

Hi,
Can you help me? I would like speeds in MPH
I have set SPEED_MPH = True, but I still get speeds in kph.
Is there something else I have to set?

TY!
Jeff

Some help with IMAGE_VIEW_FT

Hi,

maybe i can get some help with the IMAGE VIEW FT value - imho there must be something wrong.
I think the speed measured is nearly double as fast as they really drive.
Heres a litte image of the road with the camera in place. Maybe the angle is the problem?

image

Im using the following calculation (320*45)/120 = 120
Rpi 3 with standard raspi cam.

Config looks like:

# Motion Event Settings
# =====================
IMAGE_VIEW_FT = 120     # Set the width in feet for the road width that the camera width sees 120px 45ft = (320*45)/120
SPEED_MPH = False       # Set the speed conversion  kph=False  mph=True
track_len_trig = 100   # Length of track to trigger speed photo Default=100
track_timeout = 1      # Number of seconds to wait after track End (prevents dual tracking)
event_timeout = 2      # Number of seconds to wait for next motion event before starting new track

# Camera Settings
# ===============
CAMERA_WIDTH = 320    # Image stream width for opencv motion scanning default=320
CAMERA_HEIGHT = 240    # Image stream height for opencv motion scanning  default=240
CAMERA_FRAMERATE = 75  # framerate for video stream default=35 90 max for V1 cam. V2 can be higher
CAMERA_ROTATION = 0    # Rotate camera image valid values are 0, 90, 180, 270
CAMERA_VFLIP = True   # Flip the camera image vertically if required
CAMERA_HFLIP = True   # Flip the camera image horizontally if required

Thanks in advance!!

A question on tracking...

In some cases I am able to see the box around the entire vehicle:

35-speed-20191020-0743331

and other times it only grabs a part of the vehicle:

27-speed-20191019-1345002

Does that tell you anything about my setup? Is the speed calculation just as accurate?

I am using a 3B with picamera @ 320x240.

TY!

config.py.720 causes error

config.py.720 causes an error running speed-cam.py

speed-cam.py version 6.8 using python2 and OpenCV2 written by Claude Pageau
Logging to Console per Variable verbose=True
Traceback (most recent call last):
File "./speed-cam.py", line 450, in
def filesToDelete(mediaDirPath, extension=image_format):
NameError: name 'image_format' is not defined

Setup tools refactor

I have a branch going on my fork that may or may not be of interest. It's almost certainly not something you would like to consume wholesale but some pieces may be of interest. My original goal was setup tools support but it evolved into a full refactor as I made changes to understand what was happening in order to make a change I needed for the previous goal, In the process I have broken some of the tooling (intentionally and accidentally), its still not complete but its at a pretty good point now. You can find the branch here https://github.com/set321go/speed-camera/tree/refactor

Config

I refactored this out into its own module, and moved from py files to ini files, it still supports the config/plugin model but i'm not sure of the value of having all the overlapping layers. The idea now is that there is a default default_config.ini which encapsulates all the options available to the application its not intended as a user editable file and is bundled inside the egg. The user can provide a config.ini which needs to be in the cwd. The config.ini file can not exist or it can have from zero to all the options, any values in this file will override the defaults.

Where values had checks inside the code I have encapsulated these in config_validation and when a value is loaded it is passed into the validation method before setting the value in the config.

SpeedCam

This has been split into multiple modules. I tried to get as much of the code out of the speed_camera function as possible. I have encapsulated most of this logic into classes, they don't have great names yet.

  • StorageUtils: deals with all the filesystem operations, rotating dir, free space, etc.
  • CSVStorageService: writing to csv not really much here but it felt appropriate to follow the sql pattern
  • SqlLiteStorageService: encapsulates the sql boilerplate
  • MotionTrack: encapsulates all the variables being used/set during a tracking loop.
  • Capture: interacts with the video stream and manipulate the frames.

I also have a set of functions in startup_helpers which are used to check environmental things are available before attempting to connect to the camera. As part of startup there are 2 loggers, there is a boot logger which is un configured and deals with logging until the config has been loaded at which point its thrown away and a new logger is configured with the provided settings.

Cli

I got rid of the cli scrips and integrated click as well as using the setup_tools entry points. The script is installed as speed-cam and the main processing loop is available as speed-cam run there is also an additional menu at speed-cam setup. speed-cam --help will spit out these options.

Calibration

I've started some calibration in the cli but I think calibration would be more accurate with some more intelligence, I thing doing it all through the webserver would be a more robust approach as would getting the user to hold a grid in the camera view at the desired location e.g. black and white checkboard with squares of a known size 50/100mm

Env

  • I'm running this all in python 3.7 with no consideration for anything 2.x
  • It's all running in a virtual environment
  • You can use pip to install the project, in the root dir of the project pip3 install . I have the necessary modules in the requirements.txt for the project so it should install them all.
  • You can create a dist with python3 setup.py sdist

blend project

HI Mr Pageauc,
it's possible to blend your project with this project : https://www.youtube.com/watch?v=rw2O3VIx7Wg , its developed by C++ , the program is : classification of vehicles and detect speed , and draw area of detect manualy with mouse+ automatic calibration .
Screenshot from 2019-11-07 15-32-10

Images not being saved in the image folder

Followed the instructions and started the program and the web server and even within the lines i am not getting any saves but i can see the red dot move across a motion target, i am testing in night time using a pi cam. Not sure how much light is required for a save.

Is there anything i could be missing to prevent the saving of images.

Sorry it was reconfigured works great

Release 6.5 Now Compatible with Unix, Windows and RPI

I have modified the speed camera code to be compatible with windows and unix platforms using a USB Web Cam as well as a RPI using either a RPI camera module or Web Cam

On windows you should run the latest version of python that includes numpy and opencv. https://www.python.org/downloads/

I have tested on my windows 7 computer and resolved compatibility issues. The new code includes
optional free disk space management feature
and
optional Creation of sub folders that triggers a new folder base on specified max files and/or age of sub folder in hours

Please raise a GitHub issue if you find and problems or have suggestions.
Claude ....

larger imgae and hight resolution

Hi sir,
i hope you are doing well, my problem it about the resolution , when i use my laptop camera the red area of detecting is large
Screenshot from 2019-09-24 12-27-04
but when i use me camera IP the area very small :
Screenshot from 2019-09-24 12-25-27

application crashing

My application often crashes. After running a trace I see this error being raised.

File "/usr/lib/python2.7/trace.py", line 819, in <module>
    main()
  File "/usr/lib/python2.7/trace.py", line 807, in main
    t.runctx(code, globs, globs)
  File "/usr/lib/python2.7/trace.py", line 513, in runctx
    exec cmd in globals, locals
  File "speed-cam.py", line 1125, in <module>
    speed_camera() # run main speed camera processing loop
  File "speed-cam.py", line 968, in speed_camera
    image_prefix)
  File "speed-cam.py", line 619, in saveRecent
    shutil.copy(filename, recentDir)
  File "/usr/lib/python2.7/shutil.py", line 119, in copy
    copyfile(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 69, in copyfile
    raise Error("`%s` and `%s` are the same file" % (src, dst))
shutil.Error: `media/images/speed-20180602-1437/speed-20180603-140835.jpg` and `media/recent/speed-20180603-140835.jpg` are the same file

The error is pretty self explanatory without diving further into the code is there a config file I could change to fix this issue? maybe a threshold or delay somewhere?

tracking vehicules

Hello
how can i use deep reinforcement learning in tracking many cars in video plzz

minor bug in speed-cam.py

Hi, Around line 1380 in speed-cam.py there is a bug in the format statement, this causes a problem when log_data_to_CSV is set to True

CAM_LOCATION is followed by a period '.' (not a comma)
quote,
CAM_LOCATION.
quote))
and the format statement is missing three placeholders
"%i,%i,%i,%i,%i,%s%s%s"
should be
"%i,%i,%i,%i,%i,%s%s%s,%s%s%s"

without these the programme crashes

Traceback (most recent call last):
  File "./speed-cam.py", line 1607, in <module>
    speed_camera() # run main speed camera processing loop
  File "./speed-cam.py", line 1398, in speed_camera
    quote))
 TypeError: not all arguments converted during string formatting

Many thanks for a brilliant programme :-)

Kirby

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.