From 7797ced5f80c5de2dfb22b8307d84845ca4f3714 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 20 Dec 2020 14:30:24 -0700 Subject: [PATCH] Add static_object_time as parameter --- src/alg.cpp | 3 +-- src/conf.cpp | 27 +++++++++++++++++++++++++-- src/conf.hpp | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/alg.cpp b/src/alg.cpp index 51172e6c..97a6a671 100644 --- a/src/alg.cpp +++ b/src/alg.cpp @@ -30,7 +30,6 @@ #define DIFF(x, y) (ABS((x)-(y))) #define NDIFF(x, y) (ABS(x) * NORM / (ABS(x) + 2 * DIFF(x, y))) #define MAXS 10000 /* max depth of stack */ -#define ACCEPT_STATIC_OBJECT_TIME 10 /* Seconds */ #define EXCLUDE_LEVEL_PERCENT 20 /* Increment for *smartmask_buffer in alg_diff_standard. */ #define SMARTMASK_SENSITIVITY_INCR 5 @@ -1017,7 +1016,7 @@ void alg_lightswitch(struct ctx_cam *cam) */ void alg_update_reference_frame(struct ctx_cam *cam, int action) { - int accept_timer = cam->lastrate * ACCEPT_STATIC_OBJECT_TIME; + int accept_timer = cam->lastrate * cam->conf->static_object_time; int i, threshold_ref; int *ref_dyn = cam->imgs.ref_dyn; unsigned char *image_virgin = cam->imgs.image_vprvcy; diff --git a/src/conf.cpp b/src/conf.cpp index e8d0a753..77d0f362 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -282,8 +282,11 @@ struct ctx_parm config_parms[] = { { "minimum_motion_frames", "# Number of images that must contain motion to trigger an event.", - 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED - }, + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED}, + { + "static_object_time", + "# Amount of time that must elapse before a new object is accepted into the image.", + 0, PARM_TYP_INT, PARM_CAT_02, WEBUI_LEVEL_LIMITED}, { "event_gap", "# Gap in seconds of no motion detected that triggers the end of an event.", @@ -1852,6 +1855,25 @@ static void conf_edit_minimum_motion_frames(struct ctx_cam *cam, std::string &pa MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","minimum_motion_frames",_("minimum_motion_frames")); } +static void conf_edit_static_object_time(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) +{ + int parm_in; + if (pact == PARM_ACT_DFLT){ + cam->conf->static_object_time = 10; + } else if (pact == PARM_ACT_SET){ + parm_in = atoi(parm.c_str()); + if (parm_in < 1) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid static_object_time %d"),parm_in); + } else { + cam->conf->static_object_time = parm_in; + } + } else if (pact == PARM_ACT_GET){ + parm = std::to_string(cam->conf->static_object_time); + } + return; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","static_object_time",_("static_object_time")); +} + static void conf_edit_event_gap(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { int parm_in; @@ -3229,6 +3251,7 @@ static void conf_edit_cat02(struct ctx_cam *cam, std::string parm_nm, std::strin } else if (parm_nm == "lightswitch_percent"){ conf_edit_lightswitch_percent(cam, parm_val, pact); } else if (parm_nm == "lightswitch_frames"){ conf_edit_lightswitch_frames(cam, parm_val, pact); } else if (parm_nm == "minimum_motion_frames"){ conf_edit_minimum_motion_frames(cam, parm_val, pact); + } else if (parm_nm == "static_object_time"){ conf_edit_static_object_time(cam, parm_val, pact); } else if (parm_nm == "event_gap"){ conf_edit_event_gap(cam, parm_val, pact); } else if (parm_nm == "pre_capture"){ conf_edit_pre_capture(cam, parm_val, pact); } else if (parm_nm == "post_capture"){ conf_edit_post_capture(cam, parm_val, pact); diff --git a/src/conf.hpp b/src/conf.hpp index 03c5eb42..97aa1689 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -86,6 +86,7 @@ int lightswitch_percent; int lightswitch_frames; int minimum_motion_frames; + int static_object_time; int event_gap; int pre_capture; int post_capture;