Index: conf.h =================================================================== --- conf.h (revision 174) +++ conf.h (working copy) @@ -88,6 +88,7 @@ char *on_event_start; char *on_event_end; const char *mask_file; + int mask_disable_motion; int smart_mask_speed; int sql_log_image; int sql_log_snapshot; Index: conf.c =================================================================== --- conf.c (revision 174) +++ conf.c (working copy) @@ -105,6 +105,7 @@ on_event_end: NULL, mask_file: NULL, smart_mask_speed: 0, + mask_disable_motion: 0, sql_log_image: 1, sql_log_snapshot: 1, sql_log_mpeg: 0, @@ -430,6 +431,15 @@ print_int }, { + "mask_disable_motion", + "# Disable all masks when motion has been detected (default: off)\n" + "# This ensures that events do not end until all motion in the frame ceases\n" + "# and not just that in un-masked areas.", + CONF_OFFSET(mask_disable_motion), + copy_bool, + print_bool + }, + { "lightswitch", "# Ignore sudden massive light intensity changes given as a percentage of the picture\n" "# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled", Index: motion.c =================================================================== --- motion.c (revision 174) +++ motion.c (working copy) @@ -650,7 +650,8 @@ static void *motion_loop(void *arg) { struct context *cnt = arg; - int i, j, detecting_motion = 0; + int i, j; + //int i, j, detecting_motion = 0; time_t lastframetime = 0; int postcap = 0; int frame_buffer_size; Index: motion.h =================================================================== --- motion.h (revision 174) +++ motion.h (working copy) @@ -246,6 +246,7 @@ #include "netcam.h" +int detecting_motion; // Moved here for global access /* Index: alg.c =================================================================== --- alg.c (revision 174) +++ alg.c (working copy) @@ -714,11 +714,28 @@ unsigned char *mask=imgs->mask; unsigned char *smartmask_final=imgs->smartmask_final; int *smartmask_buffer=imgs->smartmask_buffer; + int mask_flag = FALSE; + int smartmask_flag = FALSE; + #ifdef HAVE_MMX mmx_t mmtemp; /* used for transferring to/from memory */ int unload; /* counter for unloading diff counts */ #endif + /* Set a flag based on the mask and smartmask state, and take into */ + /* account 'detecting_motion' if the conf setting mask_disable_motion */ + /* tells us to do so. */ + + if (cnt->conf.mask_disable_motion && detecting_motion) + mask_flag = FALSE; + else if (mask) + mask_flag = TRUE; + + if (cnt->conf.mask_disable_motion && detecting_motion) + smartmask_flag = FALSE; + else if (smartmask_speed) + smartmask_flag = TRUE; + /* If the average level of the picture is to low, compensate by * lowering the noise threshold */ @@ -797,7 +814,7 @@ punpckhbw_r2r(mm4, mm1); /* U: mm1 = d7 d6 d5 d4 */ - if (mask) { + if (mask_flag) { /* Load and expand 8 mask bytes to words in mm2 and mm3. Then * multiply by mm0 and mm1, respectively. */ @@ -853,7 +870,7 @@ /* Each fX is the "motion flag" = 0 for no motion, 0xff for motion. */ packuswb_r2r(mm1, mm0); /* U: mm0 = f7 f6 f5 f4 f3 f2 f1 f0 */ - if (smartmask_speed) { + if (smartmask_flag) { /* Apply the smartmask. Basically, if *smartmask_final is 0, the * corresponding "motion flag" in mm0 will be reset. */