Created
April 12, 2015 06:57
-
-
Save seven1240/90ea297d5a9dfc570fb2 to your computer and use it in GitHub Desktop.
cv diff with scale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/mod/applications/mod_cv/mod_cv.cpp b/src/mod/applications/mod_cv/mod_cv.cpp | |
index faee56f..f12ad00 100644 | |
--- a/src/mod/applications/mod_cv/mod_cv.cpp | |
+++ b/src/mod/applications/mod_cv/mod_cv.cpp | |
@@ -96,7 +96,7 @@ typedef struct cv_context_s { | |
struct detect_stats nestDetected; | |
int detect_event; | |
int nest_detect_event; | |
- switch_png_t *png; | |
+ switch_image_t *png; | |
struct shape shape[MAX_SHAPES]; | |
int shapeidx; | |
int x_off; | |
@@ -121,7 +121,7 @@ static void uninit_context(cv_context_t *context) | |
} | |
if (context->png) { | |
- switch_png_free(&context->png); | |
+ switch_img_free(&context->png); | |
} | |
} | |
@@ -137,7 +137,8 @@ static void init_context(cv_context_t *context, const char *cascade_name, const | |
if (nested_cascade_name) { | |
if (switch_stristr(".png", nested_cascade_name)) { | |
- switch_png_open(&context->png, nested_cascade_name); | |
+ // switch_png_open(&context->png, nested_cascade_name); | |
+ context->png = switch_img_read_png(nested_cascade_name, SWITCH_IMG_FMT_ARGB); | |
context->x_off = x_off; | |
context->y_off = y_off; | |
} else { | |
@@ -609,11 +610,15 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi | |
if (context->png && context->detect_event && context->shape[0].cx) { | |
int x = 0, y = 0; | |
+ switch_image_t *img = NULL; | |
- x = context->shape[0].cx - (context->png->w / 2) + context->x_off; | |
- y = context->shape[0].cy - (context->png->h / 2) + context->y_off; | |
+ x = context->shape[0].cx - (context->png->d_w / 4) + context->x_off; | |
+ y = context->shape[0].cy - (context->png->d_h / 4) + context->y_off; | |
- switch_png_patch_img(context->png, frame->img, x, y); | |
+ switch_img_scale(context->png, &img, context->png->d_w/2, context->png->d_h/2); | |
+ switch_img_patch(frame->img, img, x, y); | |
+ switch_img_free(&img); | |
+ // switch_png_patch_img(context->png, frame->img, x, y); | |
} else { | |
libyuv::RGB24ToI420((uint8_t *)context->rawImage->imageData, w * 3, | |
frame->img->planes[0], frame->img->stride[0], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment