From 18d1762a5be7edc7cf81d6431d64ef3d18b85b5c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 16 Nov 2016 16:05:59 -0600 Subject: [PATCH] FS-9742 --- .../mod_conference/conference_video.c | 18 ++++++++---------- src/mod/applications/mod_cv/mod_cv.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index 46d14de653..5cbbac7683 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -438,19 +438,18 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg, cropsize = 1; } else { cropsize = layer->bug_frame.geometry.x - (new_w / 2); + if (cropsize > img->d_w - new_w) { + cropsize = img->d_w - new_w; + } } } else { cropsize = (img->d_w - new_w) / 2; } - if (cropsize > img->d_w - new_w) { - cropsize = img->d_w - new_w; - } - if (cropsize < 1) { cropsize = 1; - } - + } + if (cropsize) { switch_img_set_rect(img, cropsize, 0, new_w, new_h); img_aspect = (double) img->d_w / img->d_h; @@ -471,15 +470,14 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg, cropsize = 1; } else { cropsize = layer->bug_frame.geometry.y - (new_h / 2); + if (cropsize > img->d_h - new_h) { + cropsize = img->d_h - new_h; + } } } else { cropsize = (img->d_h - new_h) / 2; } - if (cropsize > img->d_h - new_h) { - cropsize = img->d_h - new_h; - } - if (cropsize < 1) { cropsize = 1; } diff --git a/src/mod/applications/mod_cv/mod_cv.cpp b/src/mod/applications/mod_cv/mod_cv.cpp index 9343030cc2..bf2aab30d4 100644 --- a/src/mod/applications/mod_cv/mod_cv.cpp +++ b/src/mod/applications/mod_cv/mod_cv.cpp @@ -113,6 +113,7 @@ typedef struct cv_context_s { int detect_event; int nest_detect_event; struct shape shape[MAX_SHAPES]; + struct shape last_shape[MAX_SHAPES]; int shape_idx; int32_t skip; int32_t skip_count; @@ -599,6 +600,10 @@ void detectAndDraw(cv_context_t *context) //printf("SCORE: %d %f %d\n", context->detected.simo_count, context->detected.avg, context->detected.last_score); + for (i = 0; i < context->shape_idx; i++) { + context->last_shape[i] = context->shape[i]; + } + context->shape_idx = 0; //memset(context->shape, 0, sizeof(context->shape[0]) * MAX_SHAPES); @@ -724,6 +729,12 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi switch_img_to_raw(frame->img, context->rawImage->imageData, context->rawImage->widthStep, SWITCH_IMG_FMT_RGB24); detectAndDraw(context); + + if (context->detect_event && context->shape_idx && + abs(context->shape[0].cx - context->last_shape[0].cx) > 200 || abs(context->shape[0].w - context->last_shape[0].w) > 200) { + context->detected.simo_count = 0; + context->detected.simo_miss_count = context->confidence_level; + } if (context->detected.simo_count > context->confidence_level) { if (!context->detect_event) {