Fix default pixel change threshold value for motion detection

This commit is contained in:
Cédric Verstraeten
2026-07-28 09:14:44 +00:00
parent 94b26cf096
commit 8175908073
2 changed files with 12 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ func ProcessMotion(motionCursor *packets.QueueCursor, configuration *models.Conf
if motionDisabled {
log.Log.Info("computervision.main.ProcessMotion(): motion detection disabled (pixelChangeThreshold set to 0), skipping.")
log.Log.Warning("computervision.main.ProcessMotion(): motion detection is DISABLED because pixelChangeThreshold is set to 0 (nil/unset would default to 150). If motion detection is expected to be running, set capture.pixelChangeThreshold to a positive value (150 recommended) or AGENT_CAPTURE_PIXEL_CHANGE, then restart/update the agent.")
} else if continuousMode && !hasMotionRegion {

View File

@@ -648,6 +648,17 @@ func applyAgentEnvVars(configuration *models.Configuration, prefix string, apply
}
}
// Motion sensitivity: nil/unset must still resolve to the default (150), not
// be left nil. An explicit 0 (temporary "disable motion detection" switch
// from the UI) is a real, non-nil value and must NOT be touched here. Only
// applied for the effective configuration (applyDefaults), not for the
// separate global/custom views, so a missing value in one layer can still be
// inherited from the other instead of being masked by this default.
if applyDefaults && configuration.Config.Capture.PixelChangeThreshold == nil {
defaultPixelChangeThreshold := 150
configuration.Config.Capture.PixelChangeThreshold = &defaultPixelChangeThreshold
}
// Signing is a new feature, so if empty we set default values. Only applied
// for the effective configuration (applyDefaults), not for the separate
// global/custom views.