diff --git a/src/capture_filter/resize.c b/src/capture_filter/resize.c index 4b48307a5..ddb0fefc9 100644 --- a/src/capture_filter/resize.c +++ b/src/capture_filter/resize.c @@ -55,6 +55,9 @@ #include "video.h" #include "video_codec.h" +#include +#include + #define MAX_TILES 16 struct module; @@ -68,8 +71,8 @@ static struct video_frame *filter(void *state, struct video_frame *in); struct opencv_tile_struct { int width; int height; - - + float scale_factor; + Mat in, out; }; struct state_resize { @@ -133,18 +136,34 @@ static void done(void *state) free(state); } -int resize(char *indata, char *outdata, unsigned int data_len, struct opencv_tile_struct *opencv){ +int resize(char *indata, char *outdata, unsigned int *data_len, struct opencv_tile_struct *opencv){ int res = 0; - //TODO RESIZE METHOD HERE!!! + if (indata == NULL || outdata == NULL || data_lent == NULL || opencv == NULL) { + return 1; + } + + opencv->in.data = indata; + opencv->out.data = outdata; + + cvtColor(opencv->in, opencv->out, CV_YUV2RGB_UYVY); + resize(out, out, Size(0,0), opencv->scale_factor, opencv->scale_factor, INTER_LINEAR); + + *data_len = out.step * out.rows * sizeof(char); return res; } -int reconfigure_opencv_tile_struct(struct opencv_tile_struct *opencv,unsigned int width, unsigned int height, int num, int denom){ +int reconfigure_opencv_tile_struct(struct opencv_tile_struct *opencv,unsigned int width, unsigned int height, float sc_fact){ int res = 0; - //TODO DALE VUEY + if (opencv == NULL || width == 0 || height == 0 || scale_factor == 0) { + return 1; + } + + opencv->in = Mat.create(height, width, CV_8UC2); + opencv->width = width; + opencv->height = height; return 0; }