Survelliance system with deep learning based people detection (YAD2K YOLO implementation ), and notification with Telegram.
The program is made of two different threads, one is always looking for movements and if there are some it's also writing the frames to video-file.The other thread get the frames in which were detected movements and then with a deep neural network (YOLO) is searching for persons, and if there are some it's sending the images to you with telegram.
The code has been tested on raspberry pi 3B with whom I got 2/3s per frame (if you run it on GPU you should reach 200frames per second), with previous versions of the raspberry pi you probably will not get good perormances :'( .
-Linux (tested on raspberry pi3 with raspbian)
-Python3
-OpenCV for Python3
-Apache2 http-server (remember to enable the apache process eg "#systemctl enable apache2;reboot")
-Tensorflow ( link For Tensorflow on raspberry Pi)
-telegram-cli(follow the installation instructions and log in with your account)
-Numpy
-Keras 2
Instructions for Raspbian:
Follow those instructions after having installed all the requirements!
git clone https://github.com/PiSimo/PiCamNN.git
cd PiCamNN
mkdir imgs
Download the tiny yolo weights(for keras 2) converted with YAD2k :
wget https://www.dropbox.com/s/xastcd4c0dv2kty/tiny.h5?dl=0 -O tiny.h5
sudo mv index.html /var/www/html/
(NOTE: If you aren't on raspbian apache's base folder might not be /var/www/html/ so check before!)
Before starting the main script you should change in picam.py some variables:
maxDays = 7
If you have stored more then maxDays videos on your devices the oldest one will be removed
baseFolder = "/var/www/html/"
Change this variable if your apache hasn't created that folder
scriptFolder = "/home/pi/PiCamNN/"
Change this variable with the path which contains the scripts and the weights
num_cam = -1
Number of cam to use (-1 means open the first one the system has read)
frame_check = 17
Number of empty frames to wait before killing the main process
time_chunck = 15
Seconds to wait before considering a new action
telegram_user = ""
Your Telegram username you will se all the images on the chat with yourself
sudo python3 picam.py
After the main loop is started,every time a person get detected by the neural net you will receive the photo on telegram (on the chat with yourself).
To see the recorded videos, from your local network you have to go with your browser on the ip of your device which is running PiCamNN and from that page you will be able to download all the videos (eg. http://192.168.0.17 ).