Cloud native camera tiler and motion detect software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Lauri Võsandi edc6d599c5 Specify S3 content expiration in README 3 days ago
app Refactor for DNS based discovery; drop h264 support 2 weeks ago
.flake8 Add linters and fix formatting issues 4 months ago
.gitignore Initial commit 7 months ago
.gitlint Add linters and fix formatting issues 4 months ago
.pre-commit-config.yaml Add linters and fix formatting issues 4 months ago
Dockerfile Refactor for DNS based discovery; drop h264 support 2 weeks ago
Jenkinsfile Add Jenkinsfile 6 days ago
README.md Specify S3 content expiration in README 3 days ago
docker-compose.yml Separate prod config from software source 4 months ago
overnode.yml Initial commit 7 months ago
requirements.txt Refactor for DNS based discovery; drop h264 support 2 weeks ago

README.md

Background

This is the software that powers cam.k-space.ee which provides access to the camera feeds. It either reads JPEG frames from mjpg-streamer instances running on the webcams. Target machines are discovered using DNS SRV records. Behind the scenes it also does motion detetion, uploads JPG screenshots to S3/Minio and inserts event metainfo to MongoDB specified by MONGO_URI.

No files are stored in local filesystem, it's basically cloud native version of https://motion-project.github.io/

Alerting

This software doesn't implement any alerting by itself. Instead use Prometheus to monitor exported metrics, alert if camera framerate drops or ROI pixels ratio exceeds threshold. For sample see https://git.k-space.ee/k-space/overnode-cluster/src/branch/master/multihomed/60_prometheus/config/cameras.yml

Running development instance

Following spins up Mongo, Minio, Mongoexpress and Prometheus:

docker-compose up --build

Event expiration

When running on MinIO use following to set screenshot expiration to 30 days:

mc ilm add ${MINIO_ALIAS:?}/kspace-mugshot --expiry-days 30

On other S3 providers see the documentation how to set object expiration

Contributing

To make sure commits are nicely formatted we use pre-commit framework. For more info see Git message conventions

pip3 install pre-commit
pre-commit install --hook-type commit-msg

Dome cams

ELP HD Cameras with ARC0330 chipset, provides raw YUV and MJPEG on /dev/video0 and h264 on /dev/video1. OS runs on GL iNet AR150 with PoE module, the PoE module seems to not deliver enough juice to the board with cam attached. In dark the photosensor turns on IR LED array and flips on the IR filter. It seems LED-s drain so many amps that flipping back the IR filter doesn't work reliably when h264 encoding is enabled, which presumably drains even more amps. MJPEG seems to be stable enough.

Suitable firmware image for AR150 can be found at https://jenkins.k-space.ee/job/openwrt-camera-image/

Note that AR150 models whose MAC prefix starts with 94:83:c4 have fixed USB 5V circuitry and they're capable of supplying 5V@0.5A. Older models whose MAC starts with e4:95:6e have faulty 5V rail design so under load voltage drops to 4.5V and cameras go nuts.

Raspberry Pi

Install mjpg-streamer from the Git repo. Set up systemd service with:

cat > /etc/systemd/system/mjpg-streamer.service << EOF
[Unit]
Description=Streams video from USB camera
After=syslog.target
After=network.target

[Service]
Type=simple
User=nobody
Group=video
ExecStart=/usr/local/bin/mjpg_streamer -i "input_uvc.so -r 1280x720 -f 5"
Restart=always
RestartSec=5
Environment=

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl restart mjpg-streamer

Some useful commands for debugging

First device supports MJPEG and YUV:

v4l2-ctl --list-formats

Output:

ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'MJPG' (Motion-JPEG, compressed)
	[1]: 'YUYV' (YUYV 4:2:2)

There is second device with h264 encoder:

v4l2-ctl --list-formats -d /dev/video1

Output:

ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'H264' (H.264, compressed)