Skip to main content

MOG2

MOG2

The mog2 component uses the BackgroundSubtractorMOG2 algorithm built into OpenCV

The algorithm is very similar to the one used in the background_subractor component. What separates them is the fact that mog2 can detect shadows and filter those out, providing a slightly more accurate motion detector.

Configuration

Configuration example
mog2:
motion_detector:
cameras:
camera_one:
detect_shadows: true
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
threshold: 25
mog2map required
MOG2 configuration.

Motion detector

A motion detector scans an image for moving parts.

info

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.

Recorder

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:

mog2:
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