Skip to content
Merged
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
16 changes: 10 additions & 6 deletions src/background-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

struct background_removal_filter : public filter_data, public std::enable_shared_from_this<background_removal_filter> {
bool enableThreshold = true;
bool stopWhenSourceIsInactive = true;
float threshold = 0.5f;
cv::Scalar backgroundColor{0, 0, 0, 0};
float contourFilter = 0.05f;
Expand Down Expand Up @@ -127,6 +128,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, "stop_when_source_is_inactive",
obs_module_text("Stop filter when source is inactive"));

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

Expand Down Expand Up @@ -236,6 +240,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, "stop_when_source_is_inactive", true);
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 @@ -277,6 +282,7 @@ void background_filter_update(void *data, obs_data_t *settings)

tf->isDisabled = true;

tf->stopWhenSourceIsInactive = obs_data_get_bool(settings, "stop_when_source_is_inactive");
tf->enableThreshold = (float)obs_data_get_bool(settings, "enable_threshold");
tf->threshold = (float)obs_data_get_double(settings, "threshold");

Expand Down Expand Up @@ -390,30 +396,28 @@ void background_filter_update(void *data, obs_data_t *settings)

void background_filter_activate(void *data)
{
obs_log(LOG_INFO, "Background filter activated");

auto *ptr = static_cast<std::shared_ptr<background_removal_filter> *>(data);
if (!ptr) {
return;
}

std::shared_ptr<background_removal_filter> tf = *ptr;
if (tf) {
if (tf && tf->stopWhenSourceIsInactive) {
obs_log(LOG_INFO, "Background filter activated");
tf->isDisabled = false;
}
}

void background_filter_deactivate(void *data)
{
obs_log(LOG_INFO, "Background filter deactivated");

auto *ptr = static_cast<std::shared_ptr<background_removal_filter> *>(data);
if (!ptr) {
return;
}

std::shared_ptr<background_removal_filter> tf = *ptr;
if (tf) {
if (tf && tf->stopWhenSourceIsInactive) {
obs_log(LOG_INFO, "Background filter deactivated");
tf->isDisabled = true;
}
}
Expand Down
Loading