Synology Surveillance Station - AI Motion Detection
If you are using Surveillance Station on your Synology NAS, then you are well aware how poor motion detection is for cameras that are outside. I would get more false alerts than I could keep track of and no amount of tweaking the settings would ever have the detection perfect.

Background
If you are using Surveillance Station on your Synology NAS, then you are well aware how poor motion detection is for cameras that are outside. I would get more false alerts than I could keep track of and no amount of tweaking the settings would ever have the detection perfect.
I had previously used Blue Iris for my NVR solution. Blue Iris users suffered for a long time with this same problem until back in 2019 a ipcamtalk user created this tool. I setup a Dell R210ii to run Blue Iris + AI Tool and it worked GREAT. No more false positives and negatives. The downside was now I had a Windows server I had to maintain that used between 60 and 70 watts of power, not to mention the noise wasn't very pleasant.
I ran the Blue Iris setup for about a year before I decided to decommission the server and use my Synology for everything - including AI based motion detection for Surveillance station.
The Solution
I did not want to have to run a Windows VM on the Synology, the solution had to be 100% Docker based. There is a Docker image out there for AI tool, and you could probably tweak it to get it work with Surveillance Station. I tried tweaking it for a bit before giving up and creating my own.
I am by no means a programmer but I can fumble along with Python and usually get to the outcome I want. Surveillance Station has an API and you can use Action Rules in the interface to generate webhooks. Using Action Rules, you can also make outside API calls. I was able to quickly come up with a solution using FastAPI (my first time using it, an awesome library).
Here is what I came up with:
- Camera detects motion, fire off an API call to my Python script using Action Rules
- Python script receives request with camera ID as the path (ex: 192.168.0.10:4242/1)
- Python script uses the Synology Surveillance Station API
(checks to make sure we have a current session, if not start a new one) to grab a snapshot from the camera, saves it to /tmp - Python script uses the DeepStack detection API to process image for objects (people, cars, dogs, etc)
- If the DeepStack API returns an object and is over 50% confidence, trigger the camera via Action Rule webhook. If DeepStack returns nothing or below 50% confidence, do nothing
How-to
You'll need to setup 2 containers, and some Action Rules inside of Surveillance Station. Once done, cross your fingers and maybe it'll work! My containers have never used more than 1.5gb of RAM together.
Action Rules
There are 2 action rules needed for each camera that will be utilizing AI based motion detection.
The first rule calls the sssAI API to start the detection, I run mine based on motion but you could have this run every few seconds or some other way.



The second rule that needs setup is what triggers the camera when we detect an object via sssAi



You will need to create these rules for every camera you have, I only am showing one here. You can tweak the actions and events as necessary. I like to record a 60 second clip when an object is detected by sssAI.
DeepStack
There is a high probability that your Synology is missing the AVX instruction set - you will want to grab the noavx version of DeepStack unless you know otherwise.
deepquestai/deepstack

We need to change two things before deployment, map port 5000 to 83 and add a variable for "VISION-DETECTION=True"


You'll need to get an API key (free!) from DeepStack. The key can be entered by browsing to http://nasip:83/
sssAI
This is the docker image I created. I would consider this an alpha release, you may encounter some teething issues. If the cartel are after you and you absolutely need your camera notifications to work, then you shouldn't use this.
You'll need to create a config folder and map this to the image - this will contain your config files.

The two config files should look like this. Edit these to fit your environment. I only have 2 cameras, you can add as many as you need.
{
"sssUrl":"http://192.168.0.10:5000",
"deepstackUrl": "http://192.168.0.10:83",
"username": "yourusername",
"password": "yourpassword"
}
The ID for the camera follows the order in which you added them to Surveillance Station. My "Back Yard" camera was the first one I added, so it is ID 1.
{
"1":
{
"name":"Back Yard",
"threshold": 50,
"triggerUrl": "URL from Action Rule to trigger the camera goes here"
},
"2":
{
"name": "Front Door",
"threshold": 50,
"triggerUrl": "URL from Action Rule to trigger the camera goes here"
}
}
Once the config files are in place, it's time to download and launch the image.

We need to mount the folder we created to /config and map port 4242 to 80


Testing and wrapping up
Now that everything is setup, go walk in front of your camera and see if it triggers. You can view the log of sssAi to see what's going on

You can see there are a lot of false positives here, but at 5:11pm we detected a person and Synology sent me an alert that was actually useful!
This is a pretty basic script that I hobbled together, I'm open to improving it where possible. I have only been using it a couple days and experienced no issues yet. I hope this can help someone out there that was as frustrated as I was with false positive alerts!