28 #include <opencv/cv.h>
29 #include <opencv/cxcore.h>
41 int depth, channels_nb;
44 else if (pixfmt ==
AV_PIX_FMT_BGRA) { depth = IPL_DEPTH_8U; channels_nb = 4; }
45 else if (pixfmt ==
AV_PIX_FMT_BGR24) { depth = IPL_DEPTH_8U; channels_nb = 3; }
48 tmpimg = cvCreateImageHeader((CvSize){picref->
video->
w, picref->
video->
h},
depth, channels_nb);
50 img->imageData = img->imageDataOrigin = picref->
data[0];
51 img->dataOrder = IPL_DATA_ORDER_PIXEL;
52 img->origin = IPL_ORIGIN_TL;
53 img->widthStep = picref->
linesize[0];
58 picref->
linesize[0] = img->widthStep;
59 picref->
data[0] = img->imageData;
90 char type_str[128] =
"gaussian";
98 sscanf(args,
"%127[^:]:%d:%d:%lf:%lf", type_str, &smooth->
param1, &smooth->
param2, &smooth->
param3, &smooth->
param4);
100 if (!strcmp(type_str,
"blur" )) smooth->
type = CV_BLUR;
101 else if (!strcmp(type_str,
"blur_no_scale")) smooth->
type = CV_BLUR_NO_SCALE;
102 else if (!strcmp(type_str,
"median" )) smooth->
type = CV_MEDIAN;
103 else if (!strcmp(type_str,
"gaussian" )) smooth->
type = CV_GAUSSIAN;
104 else if (!strcmp(type_str,
"bilateral" )) smooth->
type = CV_BILATERAL;
112 "Invalid value '%d' for param1, it has to be a positive odd number\n",
116 if ((smooth->
type == CV_BLUR || smooth->
type == CV_BLUR_NO_SCALE || smooth->
type == CV_GAUSSIAN) &&
119 "Invalid value '%d' for param2, it has to be zero or a positive odd number\n",
143 if ((ret =
av_file_map(filename, &buf, &size, 0, log_ctx)) < 0)
148 for (i = 0; i <
size; i++) {
149 if (buf[i] ==
'\n') {
150 if (*rows == INT_MAX) {
155 *cols =
FFMAX(*cols, w);
157 }
else if (w == INT_MAX) {
163 if (*rows > (SIZE_MAX /
sizeof(
int) / *cols)) {
168 if (!(*values =
av_mallocz(
sizeof(
int) * *rows * *cols)))
174 for (i = 0; i < *rows; i++) {
176 if (p > pend || *p ==
'\n') {
180 (*values)[*cols*i + j] = !!
av_isgraph(*(p++));
190 for (i = 0; i < *rows; i++) {
191 for (j = 0; j < *cols; j++)
192 line[j] = (*values)[i * *cols + j] ?
'@' :
' ';
205 char shape_filename[128] =
"", shape_str[32] =
"rect";
206 int cols = 0, rows = 0, anchor_x = 0, anchor_y = 0, shape = CV_SHAPE_RECT;
207 int *values =
NULL, ret;
209 sscanf(buf,
"%dx%d+%dx%d/%32[^=]=%127s", &cols, &rows, &anchor_x, &anchor_y, shape_str, shape_filename);
211 if (!strcmp(shape_str,
"rect" )) shape = CV_SHAPE_RECT;
212 else if (!strcmp(shape_str,
"cross" )) shape = CV_SHAPE_CROSS;
213 else if (!strcmp(shape_str,
"ellipse")) shape = CV_SHAPE_ELLIPSE;
214 else if (!strcmp(shape_str,
"custom" )) {
215 shape = CV_SHAPE_CUSTOM;
220 "Shape unspecified or type '%s' unknown.\n", shape_str);
224 if (rows <= 0 || cols <= 0) {
226 "Invalid non-positive values for shape size %dx%d\n", cols, rows);
230 if (anchor_x < 0 || anchor_y < 0 || anchor_x >= cols || anchor_y >= rows) {
232 "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",
233 anchor_x, anchor_y, cols, rows);
237 *kernel = cvCreateStructuringElementEx(cols, rows, anchor_x, anchor_y, shape, values);
243 rows, cols, anchor_x, anchor_y, shape_str);
256 char default_kernel_str[] =
"3x3+0x0/rect";
258 const char *buf = args;
266 *kernel_str ? kernel_str : default_kernel_str,
286 cvReleaseStructuringElement(&dilate->
kernel);
320 char name[128], priv_args[1024];
324 sscanf(args,
"%127[^=:]%c%1023s", name, &c, priv_args);
328 if (!strcmp(name, entry->
name)) {
336 return ocv->
init(ctx, priv_args);
351 memset(ocv, 0,
sizeof(*ocv));
360 IplImage inimg, outimg;
407 .
inputs = avfilter_vf_ocv_inputs,
409 .
outputs = avfilter_vf_ocv_outputs,