Skip to content

csuhj/cattracker2000

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cat Tracker 2000

Cat tracker in action

This is a small python application that tracks cats (and other movement) on a Raspberry Pi.

It uses OpenCV to perform the motion detection.

The project was based on a couple of blog posts by Adrian Rosebrock

Contents

Prerequisites

  • A Raspberry Pi (3 Model B+ or above is recommended, perhaps a Raspberry Pi 4 B)
  • A nice big Micro SD Card from Amazon?
  • A camera (i.e. an infra-red wide-angle lense camera with built-in infra-red LEDs from Pimoroni)
  • Raspbian "Buster" (available from the raspberrypi.org website)
  • Python 3 (included with "Buster")
  • OpenCV (see below...)

Cat tracker in situ

I got the following instructions from this blog post to set up OpenCV:

  1. Get a Raspberry Pi 3 B+ or 4 B.
  2. Ensure it is running Raspbian "Buster". (see the above link in the prerequisites, the above blog post or Google for how to do this).
  3. Ensure you have "Expanded the filesystem". Do this by running the raspi-config tool using sudo and choosing Advanced Options -> Expand Filesystem.
  4. Also ensure that the camera is enabled using raspi-config by going into the Interfacing Options section.
  5. Reboot your Pi (sudo reboot)
  6. Install a boat-load of dependencies (again see the post for what they all are):
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libfontconfig1-dev libcairo2-dev
sudo apt-get install libgdk-pixbuf2.0-dev libpango1.0-dev
sudo apt-get install libgtk2.0-dev libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-103
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
sudo apt-get install python3-dev
  1. Install pip and virtualenv:
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo python3 get-pip.py
sudo rm -rf ~/.cache/pip
sudo pip install virtualenv virtualenvwrapper
  1. Set up your virtualenv. Run nano ~/.bashrc and then add the following to the BOTTOM of the file:
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh

Save and exit. Then reload the .bashrc to ensure it is being used:

source ~/.bashrc

Then make your "cv" virtualenv:

mkvirtualenv cv -p python3
  1. Install picamera:
pip install "picamera[array]"
  1. Install opencv:
pip install opencv-contrib-python==4.1.0.25
  1. Test the install:
cd ~
workon cv
python
>>> import cv2
>>> cv2.__version__
'4.1.0'
>>>

If this works then all is good!

Usage

Then run the application at the command line using:

python3 pi_surveillance.py --conf config.json

By default it will detect motion and save images into a ./images subdirectory.

About

Motion detection to track a... cat (or anything actually)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages