FS-9742
This commit is contained in:
parent
a3a39f3305
commit
4cf0ff9a17
|
@ -365,6 +365,33 @@ void conference_video_reset_layer(mcu_layer_t *layer)
|
|||
switch_img_free(&layer->cur_img);
|
||||
}
|
||||
|
||||
static void set_pan(mcu_layer_t *layer, int crop_point, int max_width)
|
||||
{
|
||||
if (layer->crop_point <= 0 || layer->crop_point > max_width) {
|
||||
layer->crop_point = crop_point;
|
||||
} else if (crop_point > layer->crop_point) {
|
||||
if (crop_point - layer->crop_point > 25) {
|
||||
layer->crop_point += 5;
|
||||
} else {
|
||||
layer->crop_point++;
|
||||
}
|
||||
|
||||
if (crop_point < layer->crop_point) {
|
||||
layer->crop_point = crop_point;
|
||||
}
|
||||
} else if (crop_point < layer->crop_point) {
|
||||
if (layer->crop_point - crop_point > 25) {
|
||||
layer->crop_point -= 5;
|
||||
} else {
|
||||
layer->crop_point--;
|
||||
}
|
||||
|
||||
if (crop_point > layer->crop_point) {
|
||||
layer->crop_point = crop_point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg, switch_bool_t freeze)
|
||||
{
|
||||
switch_image_t *IMG, *img;
|
||||
|
@ -421,7 +448,7 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
|||
|
||||
if (layer->last_img_addr != img_addr && layer->geometry.zoom) {
|
||||
uint32_t new_w = 0, new_h = 0;
|
||||
int cropsize = 0;
|
||||
int crop_point = 0;
|
||||
double scale = 1;
|
||||
|
||||
if (screen_aspect < img_aspect) {
|
||||
|
@ -434,19 +461,23 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
|||
new_h = (uint32_t)((double)layer->screen_h / scale);
|
||||
|
||||
if (layer->bug_frame.geometry.w) {
|
||||
cropsize = layer->bug_frame.geometry.x - (new_w / 2);
|
||||
//new_w = layer->bug_frame.geometry.w * 2;
|
||||
//new_h = new_w / screen_aspect;
|
||||
crop_point = switch_round_to_step(layer->bug_frame.geometry.x - (new_w / 2), 25);
|
||||
} else {
|
||||
cropsize = (img->d_w - new_w) / 2;
|
||||
crop_point = (img->d_w - new_w) / 2;
|
||||
}
|
||||
|
||||
if (cropsize < 1) {
|
||||
cropsize = 1;
|
||||
} else if (cropsize > img->d_w - new_w) {
|
||||
cropsize = img->d_w - new_w;
|
||||
if (crop_point < 1) {
|
||||
crop_point = 1;
|
||||
} else if (crop_point > img->d_w - new_w) {
|
||||
crop_point = img->d_w - new_w;
|
||||
}
|
||||
|
||||
if (cropsize > 0) {
|
||||
switch_img_set_rect(img, cropsize, 0, new_w, new_h);
|
||||
set_pan(layer, crop_point, img->d_w - new_w);
|
||||
|
||||
if (layer->crop_point > 0) {
|
||||
switch_img_set_rect(img, layer->crop_point, 0, new_w, new_h);
|
||||
img_aspect = (double) img->d_w / img->d_h;
|
||||
}
|
||||
|
||||
|
@ -460,20 +491,22 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
|||
new_w = (uint32_t)((double)layer->screen_w / scale);
|
||||
new_h = (uint32_t)((double)layer->screen_h / scale);
|
||||
|
||||
if (layer->bug_frame.geometry.y) {
|
||||
cropsize = layer->bug_frame.geometry.y - (new_h / 2);
|
||||
if (layer->bug_frame.geometry.w) {
|
||||
crop_point = layer->bug_frame.geometry.y - (new_h / 2);
|
||||
} else {
|
||||
cropsize = (img->d_h - new_h) / 2;
|
||||
crop_point = (img->d_h - new_h) / 2;
|
||||
}
|
||||
|
||||
if (cropsize < 1) {
|
||||
cropsize = 1;
|
||||
} else if (cropsize > img->d_h - new_h) {
|
||||
cropsize = img->d_h - new_h;
|
||||
if (crop_point < 1) {
|
||||
crop_point = 1;
|
||||
} else if (crop_point > img->d_h - new_h) {
|
||||
crop_point = img->d_h - new_h;
|
||||
}
|
||||
|
||||
if (cropsize > 0) {
|
||||
switch_img_set_rect(img, 0, cropsize, (unsigned int)(layer->screen_w/scale), (unsigned int)(layer->screen_h/scale));
|
||||
set_pan(layer, crop_point, img->d_h - new_h);
|
||||
|
||||
if (crop_point > 0) {
|
||||
switch_img_set_rect(img, 0, crop_point, (unsigned int)(layer->screen_w/scale), (unsigned int)(layer->screen_h/scale));
|
||||
img_aspect = (double) img->d_w / img->d_h;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -446,6 +446,7 @@ typedef struct mcu_layer_s {
|
|||
int refresh;
|
||||
int clear;
|
||||
int is_avatar;
|
||||
int crop_point;
|
||||
switch_size_t last_img_addr;
|
||||
switch_img_position_t logo_pos;
|
||||
switch_image_t *img;
|
||||
|
|
|
@ -693,7 +693,6 @@ void detectAndDraw(cv_context_t *context)
|
|||
switch_mutex_unlock(context->mutex);
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t video_thread_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
|
||||
{
|
||||
cv_context_t *context = (cv_context_t *) user_data;
|
||||
|
@ -730,11 +729,28 @@ 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) {
|
||||
if (context->shape_idx && context->shape[0].w && context->last_shape[0].w) {
|
||||
int max, min;
|
||||
int pct;
|
||||
|
||||
if (context->shape[0].w > context->last_shape[0].w) {
|
||||
max = context->shape[0].w;
|
||||
min = context->last_shape[0].w;
|
||||
} else {
|
||||
max = context->last_shape[0].w;
|
||||
min = context->shape[0].w;
|
||||
}
|
||||
|
||||
pct = 100 - (((double)min / (double)max) * 100.0f );
|
||||
|
||||
if (pct > 25) {
|
||||
context->detected.simo_count = 0;
|
||||
memset(context->last_shape, 0, sizeof(context->last_shape[0]) * MAX_SHAPES);
|
||||
if (context->detect_event) {
|
||||
context->detected.simo_miss_count = context->confidence_level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context->detected.simo_count > context->confidence_level) {
|
||||
if (!context->detect_event) {
|
||||
|
@ -772,6 +788,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
|||
|
||||
|
||||
memset(context->shape, 0, sizeof(context->shape[0]) * MAX_SHAPES);
|
||||
memset(context->last_shape, 0, sizeof(context->last_shape[0]) * MAX_SHAPES);
|
||||
|
||||
switch_channel_execute_on(channel, "execute_on_cv_detect_off_primary");
|
||||
reset_stats(&context->nestDetected);
|
||||
|
|
Loading…
Reference in New Issue