This project has been developed to provide a small AI capability to motionEye security system and help to analyse if the motion came from a person moving in the field. In case of recognized person, it will automatically send and email with the attached picture.
The main goal, on top of learning more about deep learning, was to add an local AI capability to the already great MotionEye project without having to pay for cloud API processing. This project uses the open source TensorFlow Lite as AI to recognize the motion. An email/alert will be send only if a person has been seen, not if a light turned on or a cat passed by.
The small server has been created as an API server that run the PI and start processing images by Path (located on the PI) or by URL.
NodeJs
,Express
,Typescript
for the API serverTensorflow Lite
as AI capability to run the model locally and test the picturenodemailer
to send emails with pre-configured SMTP serverPM2
To start eh service in production ready and configure the service to restart then the pi restartraspap
To create a GUI to configure the wifi hotspot of the different camera (raspap.com)[https://raspap.com/]
If you don't want to configure and run this project on a raspberry pi, you can use docker to deploy the app.
- update the
.env
file with your SMTP variables - Run docker:
docker build -t me/motion-detection-api .
docker run -p 5000:5000 me/motion-detection-api
NOTE: This project is still in progress, while the configuration of the pi with the motionEye
script works great, the motion-detection-api
service still has some performance issue. You need to use @tensorflow/tfjs
instead of @tensorflow/tfjs-node
since the node version does not install well in PI as of now. This result in an important performance drop.
- Download raspbian light,
- Use balenaEtcher to burn the image into the SD card,
- Add
ssh
orssh.txt
file into the/boot
folder before removing the SD card, - Put the SD card in the Pi and connect it to the wired network,
- Connect with ssh:
ssh pi@raspberrypi
password:raspberry
.
To help getting started, I created an install script raspbian-setup.sh
. From a fresh rasbian install, it configures all you need for MotionEye to work with few more dependencies (Nodejs, C++ compiler). This script need to be run as sudo to work properly.
wget --no-check-certificate --content-disposition https://github.com/R0muald/motioneye-detection/archive/master.zip
unzip motion-detection-api-master.zip
mv motion-detection-api-master motion-detection
cd ./motion-detection
sudo chmod +x raspbian-setup.sh
sudo ./raspbian-setup.sh
restart your py:
sudo reboot
Update .env.local
with your own MAIL configuration then run it:
cd ./motion-detection
yarn install
yarn build
pm2-runtime pm2-process.json
# boot strategy
pm2 startup
pm2 save
From MotionEye web interface (http://<IP_PI>:8765), you can now configure the Motion Notification
web hook with POST (form) and the URL to http://localhost:5000/notify/?path=<SNAPSHOT_URL>&email=<EMAIL_ADDRESS>
.
Configure pi as a hotspot with raspap
Once Raspap installed, you will need to open the web interface and configure the hotspot:
- Basic Tab:
- SSID: <YOUR_SSID_NAME> (store it somewhere)
- Wireless mode:
802.11n - 2.4GHz
(to be compatible with the Raspberry Pi zero W)
- Security Tab:
- type:
WPA
- encryption:
CCMP
- PSK: <YOUR_PSK_KEY> (store it somewhere)
- type:
- Advanced Tab:
- Hide SSID in broadcast:
Enabled
- Hide SSID in broadcast:
Configure Pi zero with motionEyeOS
- Download the latest stable release
img
file (https://github.com/ccrisan/motioneyeos/releases) - Use Ether.io to burn a SD card with the image
- Before putting the card in the RPI Zero,
- If you want to access the pi with
ssh
, create an emptyssh.txt
orssh
file at the root of the SD card (usually called/boot
) - Create a file called
wpa_supplicant.conf
with:update_config=1 ap_scan=1 ctrl_interface=/var/run/wpa_supplicant network={ scan_ssid=1 ssid="<YOUR_SSID_NAME>" psk="<YOUR_PSK_KEY>" key_mgmt=WPA-PSK }
- If you want to access the pi with