diff --git a/src/alg.cpp b/src/alg.cpp index 9745c706..beacf0ae 100644 --- a/src/alg.cpp +++ b/src/alg.cpp @@ -20,6 +20,8 @@ #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 #define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \ if (sp= 0 && Y+(DY) < height) \ @@ -916,8 +918,6 @@ void alg_switchfilter(struct ctx_cam *cam) { * action - UPDATE_REF_FRAME or RESET_REF_FRAME * */ -#define ACCEPT_STATIC_OBJECT_TIME 10 /* Seconds */ -#define EXCLUDE_LEVEL_PERCENT 20 void alg_update_reference_frame(struct ctx_cam *cam, int action) { int accept_timer = cam->lastrate * ACCEPT_STATIC_OBJECT_TIME; @@ -1156,40 +1156,44 @@ static void alg_new_stddev(ctx_cam *cam){ * The above is the default if nothing is specified by the user. */ if (cam->conf->threshold_sdevx >0){ - if (cam->current_image->location.stddev_x < cam->conf->threshold_sdevx){ + if (cam->current_image->location.stddev_x > cam->conf->threshold_sdevx){ cam->current_image->diffs = 0; return; } - } else { + } else if (cam->conf->threshold_sdevy >0){ + if (cam->current_image->location.stddev_y > cam->conf->threshold_sdevy){ + cam->current_image->diffs = 0; + return; + } + } else if (cam->conf->threshold_sdevxy >0){ + if (cam->current_image->location.stddev_xy > cam->conf->threshold_sdevxy){ + cam->current_image->diffs = 0; + return; + } + } + + /* Default standard deviation testing. The 8 is just a developer choice of + * that would say if the deviation is within 1/8th of the screen count it + */ + if ((cam->conf->threshold_sdevxy == 0) && + (cam->conf->threshold_sdevx == 0) && + (cam->conf->threshold_sdevy == 0)) { + chk_stddev = (long)((cam->imgs.width/8) - cam->current_image->location.stddev_x); - if (chk_stddev < 0) { + if (chk_stddev > 0) { cam->current_image->diffs = 0; return; } - } - if (cam->conf->threshold_sdevy >0){ - if (cam->current_image->location.stddev_y < cam->conf->threshold_sdevy){ - cam->current_image->diffs = 0; - return; - } - } else { chk_stddev = (long)((cam->imgs.height/8) - cam->current_image->location.stddev_y); - if (chk_stddev < 0) { + if (chk_stddev > 0) { cam->current_image->diffs = 0; return; } - } - if (cam->conf->threshold_sdevxy >0){ - if (cam->current_image->location.stddev_xy < cam->conf->threshold_sdevxy){ - cam->current_image->diffs = 0; - return; - } - } else { chk_stddev = (long)((sqrt(cam->imgs.height*cam->imgs.width)/8) - cam->current_image->location.stddev_xy); - if (chk_stddev < 0) { + if (chk_stddev > 0) { cam->current_image->diffs = 0; return; } @@ -1229,12 +1233,16 @@ static void alg_new_diff_base(ctx_cam *cam) { } cam->current_image->diffs = diffs; + return; + } void alg_new_diff(ctx_cam *cam) { alg_new_diff_base(cam); + alg_despeckle(cam); + alg_new_location(cam); alg_new_update_frame(cam); diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 90be0170..cd6e974e 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -989,15 +989,26 @@ static void mlp_overlay(struct ctx_cam *cam){ } if (cam->motapp->setup_mode || (cam->stream.motion.cnct_count > 0)) { - sprintf(tmp, "D:%5d L:%3d N:%3d", cam->current_image->diffs, + if (cam->conf->primary_method == 0){ + sprintf(tmp, "D:%5d L:%3d N:%3d", cam->current_image->diffs, cam->current_image->total_labels, cam->noise); - draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height, - cam->imgs.width - 10, cam->imgs.height - (30 * cam->text_scale), - tmp, cam->text_scale); - sprintf(tmp, "THREAD %d SETUP", cam->threadnr); - draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height, - cam->imgs.width - 10, cam->imgs.height - (10 * cam->text_scale), - tmp, cam->text_scale); + draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height, + cam->imgs.width - 10, cam->imgs.height - (30 * cam->text_scale), + tmp, cam->text_scale); + sprintf(tmp, "THREAD %d SETUP", cam->threadnr); + draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height, + cam->imgs.width - 10, cam->imgs.height - (10 * cam->text_scale), + tmp, cam->text_scale); + } else { + sprintf(tmp, "D:%5d xy:%3d x:%3d y:%3d" + , cam->current_image->diffs + , cam->current_image->location.stddev_xy + , cam->current_image->location.stddev_x + , cam->current_image->location.stddev_y); + draw_text(cam->imgs.image_motion.image_norm, cam->imgs.width, cam->imgs.height, + cam->imgs.width - 10, cam->imgs.height - (30 * cam->text_scale), + tmp, cam->text_scale); + } } /* Add text in lower left corner of the pictures */