3 * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Alternatively, the contents of this file may be used under the
24 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
25 * which case the following provisions apply instead of the ones
28 * This library is free software; you can redistribute it and/or
29 * modify it under the terms of the GNU Library General Public
30 * License as published by the Free Software Foundation; either
31 * version 2 of the License, or (at your option) any later version.
33 * This library is distributed in the hope that it will be useful,
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 * Library General Public License for more details.
38 * You should have received a copy of the GNU Library General Public
39 * License along with this library; if not, write to the
40 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
41 * Boston, MA 02110-1301, USA.
45 * SECTION:element-cverode
47 * Erodes the image with the cvErode OpenCV function.
50 * <title>Example launch line</title>
52 * gst-launch-1.0 videotestsrc ! cverode ! videoconvert ! autovideosink
61 #include "gstcverode.h"
62 #include <opencv2/imgproc.hpp>
63 #if (CV_MAJOR_VERSION >= 4)
64 #include <opencv2/imgproc/imgproc_c.h>
67 GST_DEBUG_CATEGORY_STATIC (gst_cv_erode_debug);
68 #define GST_CAT_DEFAULT gst_cv_erode_debug
70 G_DEFINE_TYPE (GstCvErode, gst_cv_erode, GST_TYPE_CV_DILATE_ERODE);
72 static GstFlowReturn gst_cv_erode_transform_ip (GstOpencvVideoFilter *
73 filter, GstBuffer * buf, IplImage * img);
75 /* initialize the cverode's class */
77 gst_cv_erode_class_init (GstCvErodeClass * klass)
79 GstOpencvVideoFilterClass *gstopencvbasefilter_class;
80 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
82 gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
84 gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_erode_transform_ip;
85 gst_element_class_set_static_metadata (element_class,
87 "Transform/Effect/Video",
88 "Applies cvErode OpenCV function to the image",
89 "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
92 /* initialize the new element
93 * instantiate pads and add them to element
94 * set pad calback functions
95 * initialize instance structure
98 gst_cv_erode_init (GstCvErode * filter)
103 gst_cv_erode_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
106 GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
108 cvErode (img, img, NULL, filter->iterations);
114 gst_cv_erode_plugin_init (GstPlugin * plugin)
116 GST_DEBUG_CATEGORY_INIT (gst_cv_erode_debug, "cverode", 0, "cverode");
118 return gst_element_register (plugin, "cverode", GST_RANK_NONE,