diff options
author | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2010-05-17 19:04:49 -0300 |
---|---|---|
committer | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2010-09-08 17:15:50 -0300 |
commit | 8f5b32f76404eb5c215d26b947a469df73ca69f4 (patch) | |
tree | 2b0935a413ae292e06356a704411e48917603a8e /ext/opencv | |
parent | f38911209d806cc436fec32239fd0b250f33cd70 (diff) |
Adds new element cvequalizehist
Diffstat (limited to 'ext/opencv')
-rw-r--r-- | ext/opencv/basicfilters/Makefile.am | 2 | ||||
-rw-r--r-- | ext/opencv/basicfilters/gstcvequalizehist.c | 134 | ||||
-rw-r--r-- | ext/opencv/basicfilters/gstcvequalizehist.h | 84 | ||||
-rw-r--r-- | ext/opencv/gstopencv.c | 4 |
4 files changed, 224 insertions, 0 deletions
diff --git a/ext/opencv/basicfilters/Makefile.am b/ext/opencv/basicfilters/Makefile.am index 61b703e91..4980beb9a 100644 --- a/ext/opencv/basicfilters/Makefile.am +++ b/ext/opencv/basicfilters/Makefile.am @@ -4,6 +4,7 @@ noinst_LTLIBRARIES = libgstbasicfilters.la libgstbasicfilters_la_SOURCES = gstcvsmooth.c \ gstcvdilateerode.c \ gstcvdilate.c \ + gstcvequalizehist.c \ gstcverode.c # flags used to compile this pyramidsegment @@ -16,4 +17,5 @@ libgstbasicfilters_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = gstcvsmooth.h \ gstcvdilateerode.h \ gstcvdilate.h \ + gstcvequalizehist.h \ gstcverode.h diff --git a/ext/opencv/basicfilters/gstcvequalizehist.c b/ext/opencv/basicfilters/gstcvequalizehist.c new file mode 100644 index 000000000..f891e5e78 --- /dev/null +++ b/ext/opencv/basicfilters/gstcvequalizehist.c @@ -0,0 +1,134 @@ +/* + * GStreamer + * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Alternatively, the contents of this file may be used under the + * GNU Lesser General Public License Version 2.1 (the "LGPL"), in + * which case the following provisions apply instead of the ones + * mentioned above: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <gst/gst.h> + +#include "gstcvequalizehist.h" + +GST_DEBUG_CATEGORY_STATIC (gst_cv_equalize_hist_debug); +#define GST_CAT_DEFAULT gst_cv_equalize_hist_debug + +static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-raw-gray, depth=(int)8, bpp=(int)8")); + +static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-raw-gray, depth=(int)8, bpp=(int)8")); + +GST_BOILERPLATE (GstCvEqualizeHist, gst_cv_equalize_hist, + GstOpencvBaseTransform, GST_TYPE_OPENCV_BASE_TRANSFORM); + +static GstFlowReturn gst_cv_equalize_hist_transform ( + GstOpencvBaseTransform * filter, GstBuffer * buf, IplImage * img, + GstBuffer * outbuf, IplImage * outimg); + +/* Clean up */ +static void +gst_cv_equalize_hist_finalize (GObject * obj) +{ + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + + +/* GObject vmethod implementations */ +static void +gst_cv_equalize_hist_base_init (gpointer gclass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_factory)); + + gst_element_class_set_details_simple (element_class, + "cvequalizehist", + "Transform/Effect/Video", + "Applies cvEqualizeHist OpenCV function to the image", + "Thiago Santos<thiago.sousa.santos@collabora.co.uk>"); +} + +static void +gst_cv_equalize_hist_class_init (GstCvEqualizeHistClass * klass) +{ + GObjectClass *gobject_class; + GstOpencvBaseTransformClass *gstopencvbasefilter_class; + + gobject_class = (GObjectClass *) klass; + gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_equalize_hist_finalize); + gstopencvbasefilter_class->cv_trans_func = gst_cv_equalize_hist_transform; +} + +static void +gst_cv_equalize_hist_init (GstCvEqualizeHist * filter, + GstCvEqualizeHistClass * gclass) +{ + gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE); +} + +static GstFlowReturn +gst_cv_equalize_hist_transform (GstOpencvBaseTransform * base, + GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg) +{ + cvEqualizeHist (img, outimg); + return GST_FLOW_OK; +} + +gboolean +gst_cv_equalize_hist_plugin_init (GstPlugin * plugin) +{ + GST_DEBUG_CATEGORY_INIT (gst_cv_equalize_hist_debug, "cvequalizehist", 0, + "cvequalizehist"); + return gst_element_register (plugin, "cvequalizehist", GST_RANK_NONE, + GST_TYPE_CV_EQUALIZE_HIST); +} diff --git a/ext/opencv/basicfilters/gstcvequalizehist.h b/ext/opencv/basicfilters/gstcvequalizehist.h new file mode 100644 index 000000000..fe22981ef --- /dev/null +++ b/ext/opencv/basicfilters/gstcvequalizehist.h @@ -0,0 +1,84 @@ +/* + * GStreamer + * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Alternatively, the contents of this file may be used under the + * GNU Lesser General Public License Version 2.1 (the "LGPL"), in + * which case the following provisions apply instead of the ones + * mentioned above: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_CV_EQUALIZE_HIST_H__ +#define __GST_CV_EQUALIZE_HIST_H__ + +#include <gst/gst.h> +#include <cv.h> +#include <gstopencvbasetrans.h> + +G_BEGIN_DECLS + +/* #defines don't like whitespacey bits */ +#define GST_TYPE_CV_EQUALIZE_HIST \ + (gst_cv_equalize_hist_get_type()) +#define GST_CV_EQUALIZE_HIST(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_EQUALIZE_HIST,GstCvEqualizeHist)) +#define GST_CV_EQUALIZE_HIST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_EQUALIZE_HIST,GstCvEqualizeHistClass)) +#define GST_IS_CV_EQUALIZE_HIST(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_EQUALIZE_HIST)) +#define GST_IS_CV_EQUALIZE_HIST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_EQUALIZE_HIST)) + +typedef struct _GstCvEqualizeHist GstCvEqualizeHist; +typedef struct _GstCvEqualizeHistClass GstCvEqualizeHistClass; + +struct _GstCvEqualizeHist +{ + GstOpencvBaseTransform element; +}; + +struct _GstCvEqualizeHistClass +{ + GstOpencvBaseTransformClass parent_class; +}; + +GType gst_cv_equalize_hist_get_type (void); + +gboolean gst_cv_equalize_hist_plugin_init (GstPlugin * plugin); + +G_END_DECLS + +#endif /* __GST_CV_EQUALIZE_HIST_H__ */ diff --git a/ext/opencv/gstopencv.c b/ext/opencv/gstopencv.c index 084e67506..77653a8a7 100644 --- a/ext/opencv/gstopencv.c +++ b/ext/opencv/gstopencv.c @@ -24,6 +24,7 @@ #endif #include "gstcvdilate.h" +#include "gstcvequalizehist.h" #include "gstcverode.h" #include "gstcvsmooth.h" #include "gstedgedetect.h" @@ -40,6 +41,9 @@ plugin_init (GstPlugin * plugin) if (!gst_cv_dilate_plugin_init (plugin)) return FALSE; + if (!gst_cv_equalize_hist_plugin_init (plugin)) + return FALSE; + if (!gst_cv_erode_plugin_init (plugin)) return FALSE; |