Background Subtractor
The background_subtractor
component utilizes a set of OpenCV functions to implement motion detection using an algorithm called background subtraction.
It works by creating a running average of frames, and then comparing the current frame to this average.
If enough changes have occurred, motion will be detected.
By using a running average, the "background" image will adjust to daylight, stationary objects etc.
This blogpost from PyImageSearch explains this procedure quite well.
Configuration
Configuration example
background_subtractor:
motion_detector:
cameras:
camera_one:
fps: 1
mask:
- coordinates:
- x: 400
y: 200
- x: 1000
y: 200
- x: 1000
y: 750
- x: 400
y: 750
camera_two:
fps: 2
trigger_recorder: true
Motion detector
A motion detector scans an image for moving parts.
Detected motion can, if configured, signal an object detector to start scanning. This is good because object detection uses far more resources compared to motion detection.
A motion detector can start the recorder if trigger_recorder
is set to true
, meaning an object detector is not strictly needed.
Mask
Masks are used to exclude certain areas in the image from motion detection. All movement within the mask will be ignored.
The coordinates
form a polygon around the masked area.
To easily generate coordinates
you can use a tool like image-map.net.
Just upload an image from your camera, choose the Poly
shape and start drawing your mask.
Then click Show me the code! and adapt it to the config format.
Coordinates coords="522,11,729,275,333,603,171,97"
should be turned into this:
background_subtractor:
motion_detector:
cameras:
camera_one:
...
mask:
- coordinates:
- x: 522
y: 11
- x: 729
y: 275
- x: 333
y: 603
- x: 171
y: 97
Paste your coordinates here and press Get config
to generate a config example