[FFmpeg-devel] [PATCH 4/4] Add ocv_erode libopencv wrapper filter.
Stefano Sabatini
stefano.sabatini-lala
Sat Sep 11 15:59:34 CEST 2010
---
configure | 1 +
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/vf_libopencv.c | 41 ++++++++++++++++++++++++++++++++++++++++-
4 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/configure b/configure
index 9453fc9..6dd1e44 100755
--- a/configure
+++ b/configure
@@ -1395,6 +1395,7 @@ udp_protocol_deps="network"
# filters
ocv_smooth_filter_deps="libopencv"
ocv_dilate_filter_deps="libopencv"
+ocv_erode_filter_deps="libopencv"
# libraries
avdevice_deps="avcodec avformat"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 394b674..32304f3 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -24,6 +24,7 @@ OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o
OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o
OBJS-$(CONFIG_NULL_FILTER) += vf_null.o
OBJS-$(CONFIG_OCV_DILATE_FILTER) += vf_libopencv.o
+OBJS-$(CONFIG_OCV_ERODE_FILTER) += vf_libopencv.o
OBJS-$(CONFIG_OCV_SMOOTH_FILTER) += vf_libopencv.o
OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o
OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index da1fedb..abdea05 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -44,6 +44,7 @@ void avfilter_register_all(void)
REGISTER_FILTER (NOFORMAT, noformat, vf);
REGISTER_FILTER (NULL, null, vf);
REGISTER_FILTER (OCV_DILATE, ocv_dilate, vf);
+ REGISTER_FILTER (OCV_ERODE, ocv_erode, vf);
REGISTER_FILTER (OCV_SMOOTH, ocv_smooth, vf);
REGISTER_FILTER (PAD, pad, vf);
REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf);
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index b0b80d0..4ced13f 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -175,7 +175,7 @@ static int parse_structuring_elem(IplConvKernel **kernel, char *buf, void *log_c
return 0;
}
-#if CONFIG_OCV_DILATE_FILTER
+#if CONFIG_OCV_DILATE_FILTER || CONFIG_OCV_ERODE_FILTER
typedef struct {
int iterations_nb;
@@ -197,6 +197,9 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args, void *opa
av_log(ctx, AV_LOG_INFO, "iterations_nb:%d\n", dilate->iterations_nb);
return 0;
}
+#endif
+
+#if CONFIG_OCV_DILATE_FILTER
static void dilate_end_frame_filter(void *priv, IplImage *inimg, IplImage *outimg)
{
@@ -232,6 +235,42 @@ AVFilter avfilter_vf_ocv_dilate = {
#endif /* CONFIG_OCV_DILATE_FILTER */
+#if CONFIG_OCV_ERODE_FILTER
+
+static void erode_end_frame_filter(void *priv, IplImage *inimg, IplImage *outimg)
+{
+ DilateContext *dilate = priv;
+ cvErode(inimg, outimg, NULL, dilate->iterations_nb);
+}
+
+static void erode_end_frame(AVFilterLink *inlink)
+{
+ ocv_end_frame(inlink, erode_end_frame_filter);
+}
+
+AVFilter avfilter_vf_ocv_erode = {
+ .name = "ocv_erode",
+ .description = "Apply erode transform using libopencv.",
+
+ .priv_size = sizeof(DilateContext),
+
+ .query_formats = query_formats,
+ .init = dilate_init,
+
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .draw_slice = null_draw_slice,
+ .end_frame = erode_end_frame,
+ .min_perms = AV_PERM_READ },
+ { .name = NULL}},
+
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO, },
+ { .name = NULL}},
+};
+
+#endif /* CONFIG_OCV_ERODE_FILTER */
+
#if CONFIG_OCV_SMOOTH_FILTER
typedef struct {
--
1.7.1
More information about the ffmpeg-devel
mailing list