A Raspberry Pi, Windows, Unix, Camera Pan-Tilt Tracker using python and opencv
YouTube Video Demo https://youtu.be/yjA3UtwbD80
YouTube Video Code Walkthrough https://youtu.be/lkh3YbbNdYg
Github Repo https://github.com/pageauc/motion-track ... /cam-track
UPDATE - 5-Sep-2016 Updated code to verion 0.85. This version is broken into more specialized functions. Most of the core code has been rewritten (more than once). This version is relatively immune to random motion in the camera view and I am happier with the performance (It can still get out of sync thought). I will work on an option to return camera movement xy positions in degrees between 0 and 360 degrees.
Let me know your comments. Thanks Claude ...
This is a raspberry pi computer openCV2 program that tracks camera (pan/tilt) movements in real time. It requires a RPI camera module installed and working. The program is written in python2 and uses openCV2.
It captures a search rectangle from the center of a video stream tread image. It then locates the rectangle in subsequent images based on a score value and returns the x y location in the image based on a threshold accuracy. If movement gets too close to the sides of the image or a suitable image search match cannot be found, then another search rectangle is selected. This data is processed to track a cumulative pixel location based on an initial camera image center value of 0,0.
This code could be used for a simple robotics application, movement stabilization, searching for an object image in the video stream rather than taking a search rectangle from the stream itself. Eg look for a dog. where the camera is mounted on a moving platform or object, Etc.
Note: This application is a demo and is currently still in development, but I thought it could still be useful, since I was not able to find a similar RPI application that does this. Will try to implement an object searcher based on this demo.
Thanks to Adrian Rosebrock jrosebr1 at http://www.pyimagesearch.com for the PiVideoStream Class
code available on github at https://github.com/jrosebr1/imutils/blo ... ostream.py
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 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
sudo apt-get update sudo apt-get upgrade sudo apt-get install -y python-opencv python-picamera mkdir ~/cam-track cd ~/cam-track wget https://raw.github.com/pageauc/motion-track/master/cam-track/cam-track.py chmod +x cam-track.py ./cam-track.py # defaults to run from RPI desktop terminal session # Set window_on=False if running in SSH session