Loading repository data…
Loading repository data…
pageauc / repository
A Unix, Windows, Raspberry Pi Object Speed Camera using python3, opencv, video streaming, motion tracking. Includes a Standalone Web Server , 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 scripts.
Note re Bullseye
speed-cam.py will run using pi camera with libcamera, picamera2 under Raspberry Pi OS Bullseye, Bookworm,and later. Usbcam and IP/RTSP cameras
are also supported. For picamera library support (on Bullseye only) Run sudo raspi-config, Interface Options, then enable Legacy Camera option and Reboot.
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.
Press GitHub copy icon on right side of code box below. Copied! will be displayed.
curl -L https://raw.github.com/pageauc/speed-camera/master/source/speed-install.sh | bash
On RPI putty SSH or terminal session right click, select paste then Enter to Download and Run speed-install.sh script.
To get started, see Instructions at the end of the install script. Initial default config.py setting is CALIBRATE_ON=True. You may also need to Align Camera using config.py ALIGN_CAM_ON=True setting. Once calibration is complete set CALIBRATE_ON=False
See Windows 10/11 or Apple Mac Docker Install Quick Start
or Windows or Unix Distro Installs without Docker
This project can run on a Raspberry Pi, Windows, Unix Distro computer. It is written in python3 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 and calculates speed based on calibration settings.
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
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
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 python3 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.
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.
config/config.py