From 2de0728f2bee419e51a897a281fbfaa47bd3416a Mon Sep 17 00:00:00 2001 From: Andrew L Date: Tue, 11 Mar 2025 15:07:43 +0100 Subject: [PATCH 1/3] Add Keep Alive property to background filter This property ensures that the background filter remains active even after switching to another scene in OBS --- src/background-filter.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/background-filter.cpp b/src/background-filter.cpp index fcc1c7f7..0fae1deb 100644 --- a/src/background-filter.cpp +++ b/src/background-filter.cpp @@ -33,6 +33,7 @@ struct background_removal_filter : public filter_data { bool enableThreshold = true; + bool keepalive = false; float threshold = 0.5f; cv::Scalar backgroundColor{0, 0, 0, 0}; float contourFilter = 0.05f; @@ -133,6 +134,9 @@ obs_properties_t *background_filter_properties(void *data) obs_property_t *advanced = obs_properties_add_bool( props, "advanced", obs_module_text("Advanced")); + obs_properties_add_bool( + props, "keepalive", obs_module_text("Keep Alive")); + // If advanced is selected show the advanced settings, otherwise hide them obs_property_set_modified_callback(advanced, enable_advanced_settings); @@ -277,6 +281,7 @@ obs_properties_t *background_filter_properties(void *data) void background_filter_defaults(obs_data_t *settings) { obs_data_set_default_bool(settings, "advanced", false); + obs_data_set_default_bool(settings, "keepalive", false); obs_data_set_default_bool(settings, "enable_threshold", true); obs_data_set_default_double(settings, "threshold", 0.5); obs_data_set_default_double(settings, "contour_filter", 0.05); @@ -311,6 +316,8 @@ void background_filter_update(void *data, obs_data_t *settings) tf->isDisabled = true; + tf->keepalive = obs_data_get_bool(settings, "keepalive"); + tf->enableThreshold = (float)obs_data_get_bool(settings, "enable_threshold"); tf->threshold = (float)obs_data_get_double(settings, "threshold"); @@ -438,17 +445,29 @@ void background_filter_update(void *data, obs_data_t *settings) void background_filter_activate(void *data) { - obs_log(LOG_INFO, "Background filter activated"); struct background_removal_filter *tf = reinterpret_cast(data); + + if (tf->keepalive) { + return; + } + + obs_log(LOG_INFO, "Background filter activated"); tf->isDisabled = false; } void background_filter_deactivate(void *data) { - obs_log(LOG_INFO, "Background filter deactivated"); struct background_removal_filter *tf = reinterpret_cast(data); + + if (tf->keepalive) { + obs_log(LOG_INFO, "Background filter keepalive"); + return; + } + + obs_log(LOG_INFO, "Background filter deactivated"); + tf->isDisabled = true; } From e86de654379e65dbb9d329cebc116ddde3eac3ee Mon Sep 17 00:00:00 2001 From: Andrew L Date: Fri, 7 Nov 2025 18:59:19 +0100 Subject: [PATCH 2/3] run clang-format on src/background-filter.cpp --- src/background-filter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/background-filter.cpp b/src/background-filter.cpp index 0fae1deb..bcaf91f8 100644 --- a/src/background-filter.cpp +++ b/src/background-filter.cpp @@ -134,8 +134,8 @@ obs_properties_t *background_filter_properties(void *data) obs_property_t *advanced = obs_properties_add_bool( props, "advanced", obs_module_text("Advanced")); - obs_properties_add_bool( - props, "keepalive", obs_module_text("Keep Alive")); + obs_properties_add_bool(props, "keepalive", + obs_module_text("Keep Alive")); // If advanced is selected show the advanced settings, otherwise hide them obs_property_set_modified_callback(advanced, enable_advanced_settings); From ff4900b57fae2aa2abffa070791c133335971aa6 Mon Sep 17 00:00:00 2001 From: Andrew L Date: Fri, 7 Nov 2025 19:13:25 +0100 Subject: [PATCH 3/3] run clang-format on src/background-filter.cpp --- src/background-filter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/background-filter.cpp b/src/background-filter.cpp index aa6d718b..977afcaf 100644 --- a/src/background-filter.cpp +++ b/src/background-filter.cpp @@ -124,8 +124,7 @@ obs_properties_t *background_filter_properties(void *data) obs_property_t *advanced = obs_properties_add_bool(props, "advanced", obs_module_text("Advanced")); - obs_properties_add_bool(props, "keepalive", - obs_module_text("Keep Alive")); + obs_properties_add_bool(props, "keepalive", obs_module_text("Keep Alive")); // If advanced is selected show the advanced settings, otherwise hide them obs_property_set_modified_callback(advanced, enable_advanced_settings);