We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

pageauc
Posts: 231
Joined: Fri Jan 04, 2013 10:52 pm

Improved python Speed Camera with threading

Sat Jul 02, 2016 8:22 pm

speed2.py
A Raspberry Pi Object Speed Camera using Video Streaming and Threading
on a Raspberry Pi Computer, Python2, OpenCV2 and Picamera Module


I have updated the SPEED2 python program at https://github.com/pageauc/motion-track ... ed-track-2
- A new install.sh has been added to make setup and updating a lot easier.. Note recently fixed a bug in this script so if there is no install.sh script in the speed2 folder then wget the latest install.sh from the github repo per quick install below.

- Updated CSV (comma separated Value) file for importing data into spreadsheet or other program for further processing

- A new speed2.sh script added to allow easy background execution from command line or at boot time via an /etc/rc.local entry. If run a second time it will display the PID of the running speed2.py process.

- Added code to detect and run under python3 but not yet fully tested. Let me know if this works for you.

I recently ran this on a RPI3 with a V2.1 Camera module and the performance with threading was amazing. Use htop to see individual processor activity (nice tool)

Code: Select all

sudo apt-get install htop
Quick Setup
Requires a Raspberry Pi computer with a RPI camera module installed, configured and tested to verify it is working. I used a RPI model B2 but a B+ , 3, zero or earlier will work OK. A quad core processor will greatly improve performance due to threading

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

Code: Select all

wget https://raw.github.com/pageauc/motion-track/master/speed-track-2/install.sh
chmod +x install.sh
./install.sh
./speed2.py

NOTE - Review settings in config.py file and edit with nano as required. You will need to perform a calibration to set the correct value for IMG_VIEW_FT variable based on the distance from camera to objects being measured for speed.
For more details See YouTube video here https://youtu.be/eRi50BbJUro (earlier version of program)
and Readme.md here https://github.com/pageauc/motion-track ... /Readme.md

Let me know what you think
Claude ...
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

Return to “Graphics, sound and multimedia”