Skip to content

Prerequisites and Install

Claude Pageau edited this page Jan 1, 2022 · 71 revisions

What's Needed and How to Get It

Requirements for Raspberry Pi Computer

A Raspberry Pi computer with a RPI camera module or web camera installed, configured and tested to verify it is working. I used a RPI model 3, B2 but a B+ or earlier will work OK. If you experience slow performance with a single core computer try replacing config.py with config.py.240 file per commands below

cd ~/speed-camera
cp config.py.240 config.py

A quad core processor will greatly improve performance and uses default 720 settings. Due to threading, a recent version of Raspbian Jessie operating system is recommended. Speed-cam.py has been tested and runs using python3 and opencv3

IMPORTANT - Review settings in config.py file and edit variables with nano or menubox.sh SETTINGS menu pick as required. You will need to perform Calibration Steps to set the correct value for cal_obj_px = and cal_obj_mm= variables based on the distance from camera to objects being measured for speed.
See YouTube Video or How to Calibrate. See Wiki for more details.

RPI Quick Curl Install

Easy Install or Upgrade of speed camera files and dependencies onto a Raspberry Pi Computer with latest Raspbian or Debian.
Step 1 Highlight curl command in code box below using mouse left button. Right click mouse in highlighted area and Copy.
Step 2 On RPI putty SSH or terminal session right click, select paste then Enter to download and run script.

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

curl command above will install required speed camera files and dependencies

RPI Manual Install

From logged in RPI SSH session or console terminal perform the following.

wget https://raw.github.com/pageauc/speed-camera/master/speed-install.sh
chmod +x speed-install.sh
./speed-install.sh
cd speed-camera
./speed-cam.py

or menubox.sh

cd ~/speed-camera
./menubox.sh

See How to Run for more details

Mac or Windows 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.

Requirements for Windows and Non RPI Unix Distro's

Requires a USB Web Camera with python installed and configured. See Details for Windows or non RPI unix distro's

NOTE If you want to try to use an IP camera here is a link to code https://github.com/BrandonJoffe/home_surveillance/blob/master/captureFeed.py You will need to change speed-cam.py to use the IP camera feed. As I do not own an IP camera Let me know if you implement this for speed-cam.py For Windows Computers access the Speed Camera GitHub page then select the green Clone download button in the top right of the web page. You can either clone or download a zip file. For a not RPI unix platform like Debian the bash curl script install should work. For additional details see Windows or Non Debian Unix Installs

Windows or Non RPI Unix Installs

For Windows or Unix computer platforms (non RPI or Debian) ensure you have the most up-to-date version of Python. See python.org Downloads. Download and run python install for your computer and Operating system. The latest python versions include numpy and a 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 Speed Camera GitHub project page then select the green Clone or download button at top right corner and select desire option. The files will then be GitHub cloned or zip file downloaded. If you are downloading zip create a suitable folder location. Default folder name is speed-camera depending on your unzip method. NOTE: If you are downloading a zip version I recommend using the free 7zip open source program or

Use curl install with Debian or compatible distro that use apt command. This should download and execute the github speed-install.sh script for the speed camera object speed tracker. This install can also be done directly on an Internet connected Raspberry Pi via a console or desktop terminal session and web browser.

You can also use git clone to copy the files to your a unix debian or compatible distro.

cd ~
git clone https://github.com/pageauc/rpi-speed-camera.git
cd speed-camera
chmod +x *sh
chmod +x *py
chmod -x config.py
chmod +x rclone-samples/*sh

The speed-cam files will be in the /home/pi/rpi-speed-camera folder. You can then move them to another location if you wish.

Note A default images folder will be created to store jpg speed photos. There is an image_path variable in the config.py file. Use nano editor to change path and/or other variables as desired.

Use the calibrate option and follow instructions below to calculate an accurate value for IMAGE_VIEW_FT variable in the speed_settings.py

You can run the code speed-cam.py from the python IDLE IDE (recommended), command prompt or GUI desktop. To Edit config.py file, use a text editor appropriate for your operating system. On windows I use the free notepad++ Editor.

Also note .sh bash scripts will NOT work on windows computers (unless bash support is installed). I have had no problem running speed-cam.py from a python IDLE session where you can easily edit configuration files as well. This would be my choice if you do not have access to a Raspberry Pi computer.