27#include <opencv2/core/core_c.h>
28#include <opencv2/imgproc/imgproc_c.h>
43 int depth, channels_nb;
50 *_img =
img = cvCreateImageHeader((CvSize){
frame->width,
frame->height}, depth, channels_nb);
51 img->imageData =
img->imageDataOrigin =
frame->data[0];
52 img->dataOrder = IPL_DATA_ORDER_PIXEL;
53 img->origin = IPL_ORIGIN_TL;
83 char type_str[128] =
"gaussian";
91 sscanf(args,
"%127[^|]|%d|%d|%lf|%lf", type_str, &
smooth->param1, &
smooth->param2, &
smooth->param3, &
smooth->param4);
93 if (!strcmp(type_str,
"blur" ))
smooth->type = CV_BLUR;
94 else if (!strcmp(type_str,
"blur_no_scale"))
smooth->type = CV_BLUR_NO_SCALE;
95 else if (!strcmp(type_str,
"median" ))
smooth->type = CV_MEDIAN;
96 else if (!strcmp(type_str,
"gaussian" ))
smooth->type = CV_GAUSSIAN;
97 else if (!strcmp(type_str,
"bilateral" ))
smooth->type = CV_BILATERAL;
105 "Invalid value '%d' for param1, it has to be a positive odd number\n",
109 if ((
smooth->type == CV_BLUR ||
smooth->type == CV_BLUR_NO_SCALE ||
smooth->type == CV_GAUSSIAN) &&
112 "Invalid value '%d' for param2, it has to be zero or a positive odd number\n",
132 uint8_t *buf, *p, *pend;
142 if (buf[
i] ==
'\n') {
143 if (*rows == INT_MAX) {
151 }
else if (
w == INT_MAX) {
157 if (*rows > (SIZE_MAX /
sizeof(
int) / *cols)) {
163 if (!(*values =
av_calloc(*cols,
sizeof(**values) * *rows))) {
171 for (
i = 0;
i < *rows;
i++) {
173 if (p > pend || *p ==
'\n') {
189 for (
i = 0;
i < *rows;
i++) {
190 for (j = 0; j < *cols; j++)
191 line[j] = (*values)[
i * *cols + j] ?
'@' :
' ';
204 char shape_filename[128] =
"", shape_str[32] =
"rect";
205 int cols = 0, rows = 0, anchor_x = 0, anchor_y = 0, shape = CV_SHAPE_RECT;
206 int *values =
NULL, ret = 0;
208 sscanf(buf,
"%dx%d+%dx%d/%31[^=]=%127s", &cols, &rows, &anchor_x, &anchor_y, shape_str, shape_filename);
210 if (!strcmp(shape_str,
"rect" )) shape = CV_SHAPE_RECT;
211 else if (!strcmp(shape_str,
"cross" )) shape = CV_SHAPE_CROSS;
212 else if (!strcmp(shape_str,
"ellipse")) shape = CV_SHAPE_ELLIPSE;
213 else if (!strcmp(shape_str,
"custom" )) {
214 shape = CV_SHAPE_CUSTOM;
219 "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);
231 if (anchor_x < 0 || anchor_y < 0 || anchor_x >= cols || anchor_y >= rows) {
233 "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",
234 anchor_x, anchor_y, cols, rows);
239 *kernel = cvCreateStructuringElementEx(cols, rows, anchor_x, anchor_y, shape, values);
246 rows, cols, anchor_x, anchor_y, shape_str);
261 char default_kernel_str[] =
"3x3+0x0/rect";
262 char *kernel_str =
NULL;
263 const char *buf = args;
274 (!kernel_str || !*kernel_str) ? default_kernel_str
281 if (!buf || sscanf(buf,
"|%d", &
dilate->nb_iterations) != 1)
282 dilate->nb_iterations = 1;
284 if (
dilate->nb_iterations <= 0) {
299 cvReleaseStructuringElement(&
dilate->kernel);
306 cvDilate(inimg, outimg,
dilate->kernel,
dilate->nb_iterations);
313 cvErode(inimg, outimg,
dilate->kernel,
dilate->nb_iterations);
341 if (!strcmp(
s->name,
entry->name)) {
343 s->uninit =
entry->uninit;
344 s->end_frame_filter =
entry->end_frame_filter;
348 return s->init(
ctx,
s->params);
371 IplImage *inimg, *outimg;
382 s->end_frame_filter(
ctx, inimg, outimg);
386 cvReleaseImageHeader(&inimg);
387 cvReleaseImageHeader(&outimg);
392#define OFFSET(x) offsetof(OCVContext, x)
393#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
420 .p.priv_class = &ocv_class,
SwsAArch64OpImplParams params
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
common internal and external API header
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_const int av_isgraph(int c)
Locale-independent conversion of ASCII isgraph.
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
enum AVPixelFormat pixfmt
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS(...)
#define AVFILTER_DEFINE_CLASS(fname)
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int(* init)(AVFilterContext *ctx, const char *args)
void(* uninit)(AVFilterContext *ctx)
void(* end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
void(* end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
void(* uninit)(AVFilterContext *ctx)
int(* init)(AVFilterContext *ctx, const char *args)
static float smooth(DeshakeOpenCLContext *deshake_ctx, float *gauss_kernel, int length, float max_val, AVFifo *values)
static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
static const AVOption ocv_options[]
static const AVFilterPad avfilter_vf_ocv_outputs[]
static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
static const AVFilterPad avfilter_vf_ocv_inputs[]
static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
static const OCVFilterEntry ocv_filter_entries[]
static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void fill_frame_from_iplimage(AVFrame *frame, const IplImage *img, enum AVPixelFormat pixfmt)
static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
static av_cold void uninit(AVFilterContext *ctx)
static int read_shape_from_file(int *cols, int *rows, int **values, const char *filename, void *log_ctx)
static av_cold void dilate_uninit(AVFilterContext *ctx)
static void fill_iplimage_from_frame(IplImage **_img, const AVFrame *frame, enum AVPixelFormat pixfmt)
static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
static int dilate(IPlane *g, IPlane *f, chord_set *SE, LUT *Ty, int y0, int y1)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.