Scene Change Detector
Scene Change Detector
The Scene Change Detector watches a camera and flags when its view changes in a way that matters - the picture goes blank, the lens is blocked, or the camera has been moved.
Overview
Each camera has a *reference* image - what its view should normally look like. The Scene Change Detector compares the live picture against that reference and reports when they differ enough to be a problem. It distinguishes a few kinds of change:
- Blank or corrupted - the picture has almost no detail (a dead or scrambled feed).
- Blockage - much of the usual detail is gone, suggesting the lens is covered or obstructed.
- Camera moved - the structure of the scene no longer matches, suggesting the camera has been repositioned.
When it detects a change it publishes a result giving the kind of change and a confidence score, which SBN can act on. The reference image can be set automatically from the first frame, or set and updated deliberately.
- Runs: When enabled. One per host.
- Required: Only for camera-tamper / scene-integrity monitoring. Not needed otherwise.
- Depends on: NATS and GStreamer (it decodes camera frames to compare them).
Configuration
The Scene Change Detector is configured under the scenechangedetector namespace. View the defaults with ./sbn-media config eject and set overrides in sbn-media.local.yaml.
| Setting | Default | Description |
|---|---|---|
scenechangedetector.enabled | false | Turn the service on. |
scenechangedetector.deviceTypes | ["rtsp"] | Which camera types to monitor. |
scenechangedetector.autoReference | false | Use the first frame as the reference when none has been set. |
scenechangedetector.ssimThreshold | 0.70 | How similar (0-1) the live scene must stay to the reference before "camera moved" is considered. |
scenechangedetector.edgeSSIMThreshold | 0.30 | The same comparison on the scene's outlines, which is less affected by lighting changes. |
scenechangedetector.edgeRatioThreshold | 0.5 | How much of the usual detail must remain before a blockage is suspected. |
scenechangedetector.varianceThreshold | 100.0 | Below this amount of picture detail, a frame is treated as blank. |
scenechangedetector.pHashThreshold | 5 | How different the overall picture may be before it counts as changed. |
scenechangedetector.frameWidth / frameHeight | 640 / 480 | The size frames are reduced to for comparison. |
scenechangedetector.storage | file | Where reference images are kept: file (local disk) or nats (shared across hosts). |
scenechangedetector.storagePath | data/scenechange | The local directory for reference images when storage is file. |
After changing these in sbn-media.local.yaml, apply them with ./sbn-media config reload.
FAQ
Nothing is being flagged.
The service is off until scenechangedetector.enabled is true and the camera's type is in scenechangedetector.deviceTypes. It also needs a reference image - set one, or turn on autoReference so the first frame is used.
It flags "camera moved" when the light changes.
Lighting can shift the picture without the camera moving. The outline-based comparison (edgeSSIMThreshold) is meant to be less sensitive to that; loosen the thresholds if normal lighting changes are being reported.
How do I update what "normal" looks like for a camera?
Set a new reference image for that camera. With autoReference on, a reference is taken automatically when none exists, but deliberate scenes are usually set explicitly.
Can references be shared across hosts?
Yes - set scenechangedetector.storage to nats so reference images are kept centrally rather than on one host's disk.
Related pages
- SBN Media Overview (
SBN-Media/overview) - Installing and Configuring SBN Media (
SBN-Media/installation) - Camera Stream (
SBN-Media/Devices/camerastream) - Image Classifier (
SBN-Media/Media-Processing/image-classifier)