Basic framework for creating headless motion detected security camera systems that runs on any hardware, including low power computers like the Raspberry Pi.
It's intended to be flexible enough to be used for a variety of sitatuions, e.g. inverval based, motion detected, save to Dropbox, save to the filesystem etc.
- Install requirements:
pip install -r requirements
- Run tests:
python -m unittest
With 'scam' installed, you need to provide a 'run' script.
Example of watching a camera constantly and uploading photos to Dropbox hourly, or if motion is detected:
from scam import source, sink, detect, pipe
import datetime
runner = pipe.MultiLoopRunner([
[
source.IpCamera('Sample', '192.168.1.30'),
pipe.Any([
detect.ContourMatcher(minimum_area=300, show_bounding_box=True),
detect.IntervalMatcher(time_delta=datetime.timedelta(hours=1)),
]),
sink.DropboxSink(
path_prefix='/Cameras/Photos/',
access_token='My Access Token'
),
sink.LoggerSink()
]
])
runner.run()
With the following results:
Frame 1
Frame 2 with Match Bounding Box
It may be useful to run scam as a service to ensure scam is running all the time. scam doesn't include this, as it's easy to get from your system.
- Windows - NSSM, or similar
- Linux, using Systemd per below
-
Create a Systemd Unit File:
$ vim /lib/systemd/system/scam.service
-
Fill it out (this may change slightly if using Virtualenv)
[Unit]
Description=Scam thingy
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/me/run.py
[Install]
WantedBy=multi-user.target
- Chmod the Unit file:
$ sudo chmod 644 /lib/systemd/system/scam.service
- Enable:
$ sudo systemctl enable scam.service
- Does scam support video input?
Not really. Only via "snapshots" for now.
- Why not Zoneminder or similar?
Zoneminder isn't really modular, nor headless. This can thus be used for remote deployments that may be behind a CGNAT, and thus not able to expose a web interface.
- What's with the
pipe
stuff?
I needed this to be highly modular as the requirements/steps were ever evolving.