OCD3 is a software network video recorder. Key features:
- low-light motion-detection,
- false-positive motion alert reduction,
- AI summation of daily events (kmeans folder).
It can use any basic computer as a personal cloud for saving and displaying motion-detected images, videos etc. Outputs can also be used in custom image searching programs e.g. making event summary videos, gathering event stats video analytics and much more.
Tested with Tapo, Sricam, PiCam, Hiseeu, and Macbook Pro cameras. The program is quite stable once started - can run for months uninterrupted. Once the program starts up, program parameters e.g. motion sensitivity and disk use can be tailored to meet the site requirements.
kmeans/
folder are RaspberryPi OS/Linux specif. Also some files in it may require editing paths at the top. Using these scripts on MacOS bash will need some tweaking. Alternatively train-km.py
and predict-km.py
produce ffnames.txt
containing full paths to images selected by KMeans over the user specified time window (train-km.py
arg3 and arg4).
- Support for KM-GEN added.
- Support for python virtual environment added.
sautils
updated to ver 3.2. A major bug inkmeans
which restricted the use of image classification to OCD camera filename format has been relaxed. Now any filename which contains timestamp as YYYYMMDD-HHMMSS will generally work.- Bug fixes.
- Version 3 has an updated motion detection scheme, which is more accurate and works better in low-light conditions.
- A heuristic to minimise excessive frame capture.
MD.log
for KMeans clustering.images_cn/
for saving contoured b/w versions of motion-detected images. Handy to know what caused motion-detection and where it occurred.- Option to increase motion-detection sensitivity after dark.
- Multiple cameras can be motion-detected with suitable mods to cam?? filenames.
crtl3-cam01
can be used to controldriver3-cam01.py
with start|stop|restart arguments e.g.crontab -e
with line,@reboot /home/saauser/bin/ctrl-cam01 start
).- A rpi4b with internal SSD ( argon one M2. enclosure) can support three camera streams quite easily.
- Version 1 has even less resource requirements and almost as good (most of my less-critical cameras still use it).
- raspberry pi 4b or a debian linux/mac PC (windows with cygwin may work - not tested)
- python 3.6 - 3.11
- work-around for accessing a rtsp stream with udp transport only remotely, SensorAnalyticsAu/remote_rtsp
Remember to pip install numpy before installing opencv.
python -m pip install -U pip
python -m pip install -U scikit-image
pip install opencv-python
pip install shutils
pip install -U scikit-learn (for kmeans)
pip install matplotlib
sudo apt update
sudo apt upgrade
sudo apt install screen
sudo apt install ffmpeg
Edit config3.py
file according to your requirements. If in doubt retain default values where appropriate.
Edit paths in the beginning of
ctrl3-cam01.sh
driver3-cam01.py
kmeans/predict-km.py
kmeans/daily-driver
moviefrm-list
moviefrm-list-ni
If using KM-GEN for frame analysis (instead of kmeans/
) then logging and gathering of additional b/w images can be turned off by setting logg = 0
in config3.py
as KM-GEN
generates its own ml data for analysis.
./ctrl3-cam01.sh start
To stop:
./ctrl3-cam01.sh stop
To check on program
screen -r cam01
ctrl-a-d (to exit)
Main reasons for program not working.
- A python dependency is missing.
- Program paths are not correctly specified.
- Incorrect camera url or camera is not working. Suggest testing camera url with VLC.
- Captured image filenames either have no timestamp or their timestamp format does not match YYYYMMDD-HHMMSS format.