Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/background-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -123,6 +124,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"));

// If advanced is selected show the advanced settings, otherwise hide them
obs_property_set_modified_callback(advanced, enable_advanced_settings);

Expand Down Expand Up @@ -223,6 +226,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);
Expand Down Expand Up @@ -253,6 +257,7 @@ 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");

Expand Down Expand Up @@ -361,15 +366,27 @@ 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<background_removal_filter *>(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<background_removal_filter *>(data);

if (tf->keepalive) {
obs_log(LOG_INFO, "Background filter keepalive");
return;
}

obs_log(LOG_INFO, "Background filter deactivated");
tf->isDisabled = true;
}

Expand Down
Loading