88 int pix_fmt = CV_8UC2;
95 rgb.create(height, width, CV_16UC3);
96 rgb.data = (uchar*)indata;
99 rgb.create(height, width, CV_8UC3);
100 rgb.data = (uchar*)indata;
103 cv_color = CV_RGBA2RGB;
110 cv_color = CV_YUV2RGB_I420;
113 cv_color = CV_YUV2RGB_UYVY;
116 cv_color = CV_YUV2RGB_YUYV;
122 yuv.create(height * num / den, width, pix_fmt);
123 yuv.data = (uchar*)indata;
124 cvtColor(yuv, rgb, cv_color);
137 int height,
int target_width,
138 int target_height,
int algo)
142 Mat rgb =
ug_to_rgb_mat(in_color, (
int) width, (
int) height, indata);
144 double in_aspect = (double) width / height;
145 double out_aspect = (double) target_width / target_height;
147 if (in_aspect == out_aspect) {
150 r.width = target_width;
151 r.height = target_height;
152 }
else if (in_aspect > out_aspect) {
154 r.width = target_width;
155 r.height = (int) (target_width / in_aspect);
156 r.y = (target_height - r.height) / 2;
159 size_t top_margin_size = r.y * linesize;
160 size_t bottom_margin_size = (target_height - r.y - r.height) * linesize;
161 memset(outdata, 0, top_margin_size);
162 memset(outdata + linesize * target_height - bottom_margin_size, 0, bottom_margin_size);
165 r.height = target_height;
166 r.width = (int) (target_height * in_aspect);
167 r.x = (target_width - r.width) / 2;
171 size_t right_margin_size =
vc_get_linesize(target_width - r.x - r.width, out_color);
172 for (
int i = 0; i < target_height; ++i) {
173 memset(outdata + i * linesize, 0, left_margin_size);
174 memset(outdata + (i + 1) * linesize - right_margin_size, 0, right_margin_size);
178 Mat out((
int) target_height, (
int) target_width,
180 resize(rgb, out(r), r.size(), 0, 0,
algo);
static void resize_frame_dimensions(char *indata, codec_t in_color, char *outdata, int width, int height, int target_width, int target_height, int algo)
void resize_frame(char *indata, codec_t in_color, char *outdata, int width, int height, struct resize_param *resize_spec)