-SUBDIRS = basicfilters edgedetect faceblur facedetect pyramidsegment templatematch textwrite
-
-# plugindir is set in configure
-
plugin_LTLIBRARIES = libgstopencv.la
# sources used to compile this plug-in
-libgstopencv_la_SOURCES = gstopencv.c gstopencvvideofilter.c gstopencvutils.c
+libgstopencv_la_SOURCES = gstopencv.c \
+ gstopencvvideofilter.c \
+ gstopencvutils.c \
+ gstcvdilate.c \
+ gstcvdilateerode.c \
+ gstcvequalizehist.c \
+ gstcverode.c \
+ gstcvlaplace.c \
+ gstcvsmooth.c \
+ gstcvsobel.c \
+ gstedgedetect.c \
+ gstfaceblur.c \
+ gstfacedetect.c \
+ gstpyramidsegment.c \
+ gsttemplatematch.c \
+ gsttextwrite.c
# flags used to compile this facedetect
# add other _CFLAGS and _LIBS as needed
libgstopencv_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(OPENCV_CFLAGS) \
- $(GSTPB_BASE_CFLAGS) \
- -I${top_srcdir}/ext \
- -I${top_srcdir}/ext/opencv/basicfilters \
- -I${top_srcdir}/ext/opencv/edgedetect \
- -I${top_srcdir}/ext/opencv/faceblur \
- -I${top_srcdir}/ext/opencv/facedetect \
- -I${top_srcdir}/ext/opencv/pyramidsegment \
- -I${top_srcdir}/ext/opencv/templatematch \
- -I${top_srcdir}/ext/opencv/textwrite
+ $(GST_PLUGINS_BASE_CFLAGS)
libgstopencv_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(OPENCV_LIBS) \
- $(GSTPB_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
- $(top_builddir)/ext/opencv/basicfilters/libgstbasicfilters.la \
- $(top_builddir)/ext/opencv/edgedetect/libgstedgedetect.la \
- $(top_builddir)/ext/opencv/faceblur/libgstfaceblur.la \
- $(top_builddir)/ext/opencv/facedetect/libgstfacedetect.la \
- $(top_builddir)/ext/opencv/pyramidsegment/libgstpyramidsegment.la \
- $(top_builddir)/ext/opencv/templatematch/libgsttemplatematch.la \
- $(top_builddir)/ext/opencv/textwrite/libgsttextwrite.la
+ $(GSTPB_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR)
libgstopencv_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstopencv_la_DEPENDENCIES = \
- $(top_builddir)/ext/opencv/basicfilters/libgstbasicfilters.la \
- $(top_builddir)/ext/opencv/edgedetect/libgstedgedetect.la \
- $(top_builddir)/ext/opencv/faceblur/libgstfaceblur.la \
- $(top_builddir)/ext/opencv/facedetect/libgstfacedetect.la \
- $(top_builddir)/ext/opencv/pyramidsegment/libgstpyramidsegment.la \
- $(top_builddir)/ext/opencv/templatematch/libgsttemplatematch.la \
- $(top_builddir)/ext/opencv/textwrite/libgsttextwrite.la
-
# headers we need but don't want installed
-noinst_HEADERS = gstopencvvideofilter.h gstopencvutils.h
+noinst_HEADERS = gstopencvvideofilter.h gstopencvutils.h \
+ gstcvdilateerode.h \
+ gstcvdilate.h \
+ gstcvequalizehist.h \
+ gstcverode.h \
+ gstcvlaplace.h \
+ gstcvsmooth.h \
+ gstcvsobel.h \
+ gstedgedetect.h \
+ gstfaceblur.h \
+ gstfacedetect.h \
+ gstpyramidsegment.h \
+ gsttemplatematch.h \
+ gsttextwrite.h
+++ /dev/null
-noinst_LTLIBRARIES = libgstbasicfilters.la
-
-# sources used to compile this plug-in
-libgstbasicfilters_la_SOURCES = gstcvsmooth.c \
- gstcvdilateerode.c \
- gstcvdilate.c \
- gstcvequalizehist.c \
- gstcvlaplace.c \
- gstcverode.c \
- gstcvsobel.c
-
-# flags used to compile this pyramidsegment
-# add other _CFLAGS and _LIBS as needed
-libgstbasicfilters_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS) -I.. \
- $(GST_BASE_CFLAGS) $(GSTPB_BASE_CFLAGS)
-libgstbasicfilters_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS) \
- $(GST_BASE_LIBS) $(GSTPB_BASE_LIBS) \
- -lgstvideo-$(GST_MAJORMINOR)
-libgstbasicfilters_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gstcvsmooth.h \
- gstcvdilateerode.h \
- gstcvdilate.h \
- gstcvequalizehist.h \
- gstcverode.h \
- gstcvlaplace.h \
- gstcvsobel.h
+++ /dev/null
-/*
- * 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 "gstcvdilate.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_cv_dilate_debug);
-#define GST_CAT_DEFAULT gst_cv_dilate_debug
-
-GST_BOILERPLATE (GstCvDilate, gst_cv_dilate, GstCvDilateErode,
- GST_TYPE_CV_DILATE_ERODE);
-
-static GstFlowReturn gst_cv_dilate_transform_ip (GstOpencvVideoFilter *
- filter, GstBuffer * buf, IplImage * img);
-static GstFlowReturn gst_cv_dilate_transform (GstOpencvVideoFilter * filter,
- GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
-
-/* GObject vmethod implementations */
-static void
-gst_cv_dilate_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "cvdilate",
- "Transform/Effect/Video",
- "Applies cvDilate OpenCV function to the image",
- "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
-}
-
-/* initialize the cvdilate's class */
-static void
-gst_cv_dilate_class_init (GstCvDilateClass * klass)
-{
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
-
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_dilate_transform_ip;
- gstopencvbasefilter_class->cv_trans_func = gst_cv_dilate_transform;
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_cv_dilate_init (GstCvDilate * filter, GstCvDilateClass * gclass)
-{
-}
-
-static GstFlowReturn
-gst_cv_dilate_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img, GstBuffer * outbuf, IplImage * outimg)
-{
- GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
-
- /* TODO support kernel as a parameter */
- cvDilate (img, outimg, NULL, filter->iterations);
-
- return GST_FLOW_OK;
-}
-
-static GstFlowReturn
-gst_cv_dilate_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img)
-{
- GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
-
- cvDilate (img, img, NULL, filter->iterations);
-
- return GST_FLOW_OK;
-}
-
-gboolean
-gst_cv_dilate_plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (gst_cv_dilate_debug, "cvdilate", 0, "cvdilate");
-
- return gst_element_register (plugin, "cvdilate", GST_RANK_NONE,
- GST_TYPE_CV_DILATE);
-}
+++ /dev/null
-/*
- * 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_DILATE_H__
-#define __GST_CV_DILATE_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include "gstcvdilateerode.h"
-
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_CV_DILATE \
- (gst_cv_dilate_get_type())
-#define GST_CV_DILATE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_DILATE,GstCvDilate))
-#define GST_CV_DILATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_DILATE,GstCvDilateClass))
-#define GST_IS_CV_DILATE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_DILATE))
-#define GST_IS_CV_DILATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_DILATE))
-
-typedef struct _GstCvDilate GstCvDilate;
-typedef struct _GstCvDilateClass GstCvDilateClass;
-
-struct _GstCvDilate
-{
- GstCvDilateErode element;
-};
-
-struct _GstCvDilateClass
-{
- GstCvDilateErodeClass parent_class;
-};
-
-GType gst_cv_dilate_get_type (void);
-
-gboolean gst_cv_dilate_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_CV_DILATE_H__ */
+++ /dev/null
-/*
- * 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.
- */
-
-/*
- * As cvdilate_erode and cverode are all the same, except for the transform function,
- * we hope this base class should keep maintenance easier.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gstcvdilateerode.h"
-
-/*
-GST_DEBUG_CATEGORY_STATIC (gst_cv_dilate_erode_debug);
-#define GST_CAT_DEFAULT gst_cv_dilate_erode_debug
-*/
-
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
- "video/x-raw-gray")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
- "video/x-raw-gray")
- );
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-enum
-{
- PROP_0,
- PROP_ITERATIONS,
-};
-
-#define DEFAULT_ITERATIONS 1
-
-static GstElementClass *parent_class = NULL;
-
-static void gst_cv_dilate_erode_base_init (gpointer gclass);
-static void gst_cv_dilate_erode_class_init (GstCvDilateErodeClass * klass);
-static void gst_cv_dilate_erode_init (GstCvDilateErode * filter,
- GstCvDilateErodeClass * gclass);
-
-static void gst_cv_dilate_erode_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_cv_dilate_erode_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-GType
-gst_cv_dilate_erode_get_type (void)
-{
- static volatile gsize opencv_dilate_erode_type = 0;
-
- if (g_once_init_enter (&opencv_dilate_erode_type)) {
- GType _type;
- static const GTypeInfo opencv_dilate_erode_info = {
- sizeof (GstCvDilateErodeClass),
- (GBaseInitFunc) gst_cv_dilate_erode_base_init,
- NULL,
- (GClassInitFunc) gst_cv_dilate_erode_class_init,
- NULL,
- NULL,
- sizeof (GstCvDilateErode),
- 0,
- (GInstanceInitFunc) gst_cv_dilate_erode_init,
- };
-
- _type = g_type_register_static (GST_TYPE_OPENCV_VIDEO_FILTER,
- "GstCvDilateErode", &opencv_dilate_erode_info,
- G_TYPE_FLAG_ABSTRACT);
-/*
- GST_DEBUG_CATEGORY_INIT (gst_cv_dilate_erode_debug, "cvdilateerode", 0,
- "cvdilateerode");
-*/
- g_once_init_leave (&opencv_dilate_erode_type, _type);
- }
- return opencv_dilate_erode_type;
-}
-
-/* Clean up */
-static void
-gst_cv_dilate_erode_finalize (GObject * obj)
-{
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-
-/* GObject vmethod implementations */
-
-static void
-gst_cv_dilate_erode_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));
-}
-
-/* initialize the cvdilate_erode's class */
-static void
-gst_cv_dilate_erode_class_init (GstCvDilateErodeClass * klass)
-{
- GObjectClass *gobject_class;
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_dilate_erode_finalize);
- gobject_class->set_property = gst_cv_dilate_erode_set_property;
- gobject_class->get_property = gst_cv_dilate_erode_get_property;
-
- g_object_class_install_property (gobject_class, PROP_ITERATIONS,
- g_param_spec_int ("iterations", "iterations",
- "Number of iterations to run the algorithm", 1, G_MAXINT,
- DEFAULT_ITERATIONS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_cv_dilate_erode_init (GstCvDilateErode * filter,
- GstCvDilateErodeClass * gclass)
-{
- filter->iterations = DEFAULT_ITERATIONS;
- gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
-}
-
-static void
-gst_cv_dilate_erode_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstCvDilateErode *filter = GST_CV_DILATE_ERODE (object);
-
- switch (prop_id) {
- case PROP_ITERATIONS:
- filter->iterations = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_cv_dilate_erode_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstCvDilateErode *filter = GST_CV_DILATE_ERODE (object);
-
- switch (prop_id) {
- case PROP_ITERATIONS:
- g_value_set_int (value, filter->iterations);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
+++ /dev/null
-/*
- * 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_DILATE_ERODE_H__
-#define __GST_CV_DILATE_ERODE_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include <gstopencvvideofilter.h>
-
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_CV_DILATE_ERODE \
- (gst_cv_dilate_erode_get_type())
-#define GST_CV_DILATE_ERODE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_DILATE_ERODE,GstCvDilateErode))
-#define GST_CV_DILATE_ERODE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_DILATE_ERODE,GstCvDilateErodeClass))
-#define GST_IS_CV_DILATE_ERODE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_DILATE_ERODE))
-#define GST_IS_CV_DILATE_ERODE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_DILATE_ERODE))
-
-typedef struct _GstCvDilateErode GstCvDilateErode;
-typedef struct _GstCvDilateErodeClass GstCvDilateErodeClass;
-
-struct _GstCvDilateErode
-{
- GstOpencvVideoFilter element;
-
- gint iterations;
-};
-
-struct _GstCvDilateErodeClass
-{
- GstOpencvVideoFilterClass parent_class;
-};
-
-GType gst_cv_dilate_erode_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_CV_DILATE_ERODE_H__ */
+++ /dev/null
-/*
- * 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,
- GstOpencvVideoFilter, GST_TYPE_OPENCV_VIDEO_FILTER);
-
-static GstFlowReturn gst_cv_equalize_hist_transform (
- GstOpencvVideoFilter * 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;
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
-
- gobject_class = (GObjectClass *) klass;
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) 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 (GstOpencvVideoFilter * 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);
-}
+++ /dev/null
-/*
- * 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 <gstopencvvideofilter.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
-{
- GstOpencvVideoFilter element;
-};
-
-struct _GstCvEqualizeHistClass
-{
- GstOpencvVideoFilterClass 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__ */
+++ /dev/null
-/*
- * 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 "gstcverode.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_cv_erode_debug);
-#define GST_CAT_DEFAULT gst_cv_erode_debug
-
-GST_BOILERPLATE (GstCvErode, gst_cv_erode, GstCvDilateErode,
- GST_TYPE_CV_DILATE_ERODE);
-
-static GstFlowReturn gst_cv_erode_transform_ip (GstOpencvVideoFilter *
- filter, GstBuffer * buf, IplImage * img);
-static GstFlowReturn gst_cv_erode_transform (GstOpencvVideoFilter * filter,
- GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
-
-/* GObject vmethod implementations */
-static void
-gst_cv_erode_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "cverode",
- "Transform/Effect/Video",
- "Applies cvErode OpenCV function to the image",
- "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
-}
-
-/* initialize the cverode's class */
-static void
-gst_cv_erode_class_init (GstCvErodeClass * klass)
-{
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
-
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_erode_transform_ip;
- gstopencvbasefilter_class->cv_trans_func = gst_cv_erode_transform;
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_cv_erode_init (GstCvErode * filter, GstCvErodeClass * gclass)
-{
-}
-
-static GstFlowReturn
-gst_cv_erode_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img, GstBuffer * outbuf, IplImage * outimg)
-{
- GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
-
- /* TODO support kernel as a parameter */
- cvErode (img, outimg, NULL, filter->iterations);
-
- return GST_FLOW_OK;
-}
-
-static GstFlowReturn
-gst_cv_erode_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img)
-{
- GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
-
- cvErode (img, img, NULL, filter->iterations);
-
- return GST_FLOW_OK;
-}
-
-gboolean
-gst_cv_erode_plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (gst_cv_erode_debug, "cverode", 0, "cverode");
-
- return gst_element_register (plugin, "cverode", GST_RANK_NONE,
- GST_TYPE_CV_ERODE);
-}
+++ /dev/null
-/*
- * 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_ERODE_H__
-#define __GST_CV_ERODE_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include "gstcvdilateerode.h"
-
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_CV_ERODE \
- (gst_cv_erode_get_type())
-#define GST_CV_ERODE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_ERODE,GstCvErode))
-#define GST_CV_ERODE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_ERODE,GstCvErodeClass))
-#define GST_IS_CV_ERODE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_ERODE))
-#define GST_IS_CV_ERODE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_ERODE))
-
-typedef struct _GstCvErode GstCvErode;
-typedef struct _GstCvErodeClass GstCvErodeClass;
-
-struct _GstCvErode
-{
- GstCvDilateErode element;
-};
-
-struct _GstCvErodeClass
-{
- GstCvDilateErodeClass parent_class;
-};
-
-GType gst_cv_erode_get_type (void);
-
-gboolean gst_cv_erode_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_CV_ERODE_H__ */
+++ /dev/null
-/*
- * 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 "gstcvlaplace.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_cv_laplace_debug);
-#define GST_CAT_DEFAULT gst_cv_laplace_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)16, bpp=(int)16, endianness=(int)4321")
- );
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-enum
-{
- PROP_0,
- PROP_APERTURE_SIZE
-};
-
-#define DEFAULT_APERTURE_SIZE 3
-
-GST_BOILERPLATE (GstCvLaplace, gst_cv_laplace, GstOpencvVideoFilter,
- GST_TYPE_OPENCV_VIDEO_FILTER);
-
-static void gst_cv_laplace_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_cv_laplace_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstCaps *gst_cv_laplace_transform_caps (GstBaseTransform * trans,
- GstPadDirection dir, GstCaps * caps);
-
-static GstFlowReturn gst_cv_laplace_transform (GstOpencvVideoFilter * filter,
- GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
-
-static gboolean gst_cv_laplace_cv_set_caps (GstOpencvVideoFilter * trans,
- gint in_width, gint in_height, gint in_depth, gint in_channels,
- gint out_width, gint out_height, gint out_depth, gint out_channels);
-
-/* Clean up */
-static void
-gst_cv_laplace_finalize (GObject * obj)
-{
- GstCvLaplace *filter = GST_CV_LAPLACE (obj);
-
- if (filter->intermediary_img)
- cvReleaseImage (&filter->intermediary_img);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-/* GObject vmethod implementations */
-
-static void
-gst_cv_laplace_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,
- "cvlaplace",
- "Transform/Effect/Video",
- "Applies cvLaplace OpenCV function to the image",
- "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
-}
-
-/* initialize the cvlaplace's class */
-static void
-gst_cv_laplace_class_init (GstCvLaplaceClass * klass)
-{
- GObjectClass *gobject_class;
- GstBaseTransformClass *gstbasetransform_class;
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasetransform_class = (GstBaseTransformClass *) klass;
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_laplace_finalize);
- gobject_class->set_property = gst_cv_laplace_set_property;
- gobject_class->get_property = gst_cv_laplace_get_property;
-
- gstbasetransform_class->transform_caps = gst_cv_laplace_transform_caps;
-
- gstopencvbasefilter_class->cv_trans_func = gst_cv_laplace_transform;
- gstopencvbasefilter_class->cv_set_caps = gst_cv_laplace_cv_set_caps;
-
- g_object_class_install_property (gobject_class, PROP_APERTURE_SIZE,
- g_param_spec_int ("aperture-size", "aperture size",
- "Size of the extended Laplace Kernel (1, 3, 5 or 7)", 1, 7,
- DEFAULT_APERTURE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-gst_cv_laplace_init (GstCvLaplace * filter, GstCvLaplaceClass * gclass)
-{
- filter->aperture_size = DEFAULT_APERTURE_SIZE;
-
- gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
-}
-
-static gboolean
-gst_cv_laplace_cv_set_caps (GstOpencvVideoFilter * trans, gint in_width,
- gint in_height, gint in_depth, gint in_channels, gint out_width,
- gint out_height, gint out_depth, gint out_channels)
-{
- GstCvLaplace *filter = GST_CV_LAPLACE (trans);
- gint intermediary_depth;
-
- /* cvLaplace needs an signed output, so we create our intermediary step
- * image here */
- switch (out_depth) {
- case IPL_DEPTH_16U:
- intermediary_depth = IPL_DEPTH_16S;
- break;
- default:
- GST_WARNING_OBJECT (filter, "Unsupported output depth %d", out_depth);
- return FALSE;
- }
-
- if (filter->intermediary_img) {
- cvReleaseImage (&filter->intermediary_img);
- }
-
- filter->intermediary_img = cvCreateImage (cvSize (out_width, out_height),
- intermediary_depth, out_channels);
-
- return TRUE;
-}
-
-static GstCaps *
-gst_cv_laplace_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
- GstCaps * caps)
-{
- GstCaps *output = NULL;
- GstStructure *structure;
- gint i;
-
- output = gst_caps_copy (caps);
-
- /* we accept anything from the template caps for either side */
- switch (dir) {
- case GST_PAD_SINK:
- for (i = 0; i < gst_caps_get_size (output); i++) {
- structure = gst_caps_get_structure (output, i);
- gst_structure_set (structure,
- "depth", G_TYPE_INT, 16,
- "bpp", G_TYPE_INT, 16, "endianness", G_TYPE_INT, 4321, NULL);
- }
- break;
- case GST_PAD_SRC:
- for (i = 0; i < gst_caps_get_size (output); i++) {
- structure = gst_caps_get_structure (output, i);
- gst_structure_set (structure,
- "depth", G_TYPE_INT, 8, "bpp", G_TYPE_INT, 8, NULL);
- gst_structure_remove_field (structure, "endianness");
- }
- break;
- default:
- gst_caps_unref (output);
- output = NULL;
- g_assert_not_reached ();
- break;
- }
-
- return output;
-}
-
-static void
-gst_cv_laplace_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstCvLaplace *filter = GST_CV_LAPLACE (object);
-
- switch (prop_id) {
- case PROP_APERTURE_SIZE:{
- gint as = g_value_get_int (value);
-
- if (as % 2 != 1) {
- GST_WARNING_OBJECT (filter, "Invalid value %d for aperture size", as);
- } else
- filter->aperture_size = g_value_get_int (value);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_cv_laplace_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstCvLaplace *filter = GST_CV_LAPLACE (object);
-
- switch (prop_id) {
- case PROP_APERTURE_SIZE:
- g_value_set_int (value, filter->aperture_size);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstFlowReturn
-gst_cv_laplace_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img, GstBuffer * outbuf, IplImage * outimg)
-{
- GstCvLaplace *filter = GST_CV_LAPLACE (base);
-
- g_assert (filter->intermediary_img);
-
- cvLaplace (img, filter->intermediary_img, filter->aperture_size);
- cvConvertScale (filter->intermediary_img, outimg, 1, 0);
-
- return GST_FLOW_OK;
-}
-
-gboolean
-gst_cv_laplace_plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (gst_cv_laplace_debug, "cvlaplace", 0, "cvlaplace");
-
- return gst_element_register (plugin, "cvlaplace", GST_RANK_NONE,
- GST_TYPE_CV_LAPLACE);
-}
+++ /dev/null
-/*
- * 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_LAPLACE_H__
-#define __GST_CV_LAPLACE_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include <gstopencvvideofilter.h>
-
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_CV_LAPLACE \
- (gst_cv_laplace_get_type())
-#define GST_CV_LAPLACE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_LAPLACE,GstCvLaplace))
-#define GST_CV_LAPLACE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_LAPLACE,GstCvLaplaceClass))
-#define GST_IS_CV_LAPLACE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_LAPLACE))
-#define GST_IS_CV_LAPLACE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_LAPLACE))
-
-typedef struct _GstCvLaplace GstCvLaplace;
-typedef struct _GstCvLaplaceClass GstCvLaplaceClass;
-
-struct _GstCvLaplace
-{
- GstOpencvVideoFilter element;
-
- gint aperture_size;
-
- IplImage *intermediary_img;
-};
-
-struct _GstCvLaplaceClass
-{
- GstOpencvVideoFilterClass parent_class;
-};
-
-GType gst_cv_laplace_get_type (void);
-
-gboolean gst_cv_laplace_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_CV_LAPLACE_H__ */
+++ /dev/null
-/*
- * 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 "gstcvsmooth.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_cv_smooth_debug);
-#define GST_CAT_DEFAULT gst_cv_smooth_debug
-
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
- "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-rgb, depth=(int)24, bpp=(int)24;"
- "video/x-raw-gray, depth=(int)8, bpp=(int)8")
- );
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-enum
-{
- PROP_0,
- PROP_SMOOTH_TYPE,
- PROP_PARAM1,
- PROP_PARAM2,
- PROP_PARAM3,
- PROP_PARAM4
-};
-
-/* blur-no-scale only handle: gray 8bits -> gray 16bits
- * FIXME there is no way in base transform to override pad's getcaps
- * to be property-sensitive, instead of using the template caps as
- * the base caps, this might lead us to negotiating rgb in this
- * smooth type.
- *
- * Keep it deactivated for now.
- */
-
-#define GST_TYPE_CV_SMOOTH_TYPE (gst_cv_smooth_type_get_type ())
-static GType
-gst_cv_smooth_type_get_type (void)
-{
- static GType cv_smooth_type_type = 0;
-
- static const GEnumValue smooth_types[] = {
-/* {CV_BLUR_NO_SCALE, "CV Blur No Scale", "blur-no-scale"}, */
- {CV_BLUR, "CV Blur", "blur"},
- {CV_GAUSSIAN, "CV Gaussian", "gaussian"},
- {CV_MEDIAN, "CV Median", "median"},
- {CV_BILATERAL, "CV Bilateral", "bilateral"},
- {0, NULL, NULL},
- };
-
- if (!cv_smooth_type_type) {
- cv_smooth_type_type =
- g_enum_register_static ("GstCvSmoothTypeType", smooth_types);
- }
- return cv_smooth_type_type;
-}
-
-#define DEFAULT_CV_SMOOTH_TYPE CV_GAUSSIAN
-#define DEFAULT_PARAM1 3
-#define DEFAULT_PARAM2 0.0
-#define DEFAULT_PARAM3 0.0
-#define DEFAULT_PARAM4 0.0
-
-GST_BOILERPLATE (GstCvSmooth, gst_cv_smooth, GstOpencvVideoFilter,
- GST_TYPE_OPENCV_VIDEO_FILTER);
-
-static void gst_cv_smooth_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_cv_smooth_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstFlowReturn gst_cv_smooth_transform_ip (GstOpencvVideoFilter *
- filter, GstBuffer * buf, IplImage * img);
-static GstFlowReturn gst_cv_smooth_transform (GstOpencvVideoFilter * filter,
- GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
-
-/* Clean up */
-static void
-gst_cv_smooth_finalize (GObject * obj)
-{
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-
-/* GObject vmethod implementations */
-
-static void
-gst_cv_smooth_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,
- "cvsmooth",
- "Transform/Effect/Video",
- "Applies cvSmooth OpenCV function to the image",
- "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
-}
-
-/* initialize the cvsmooth's class */
-static void
-gst_cv_smooth_class_init (GstCvSmoothClass * klass)
-{
- GObjectClass *gobject_class;
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_smooth_finalize);
- gobject_class->set_property = gst_cv_smooth_set_property;
- gobject_class->get_property = gst_cv_smooth_get_property;
-
- gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_smooth_transform_ip;
- gstopencvbasefilter_class->cv_trans_func = gst_cv_smooth_transform;
-
- g_object_class_install_property (gobject_class, PROP_SMOOTH_TYPE,
- g_param_spec_enum ("type",
- "type",
- "Smooth Type",
- GST_TYPE_CV_SMOOTH_TYPE,
- DEFAULT_CV_SMOOTH_TYPE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
- g_object_class_install_property (gobject_class, PROP_PARAM1,
- g_param_spec_int ("param1", "param1 (aperture width)",
- "The aperture width (Must be positive and odd)."
- "Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
- "/documentation/image_filtering.html#cvSmooth", 1, G_MAXINT,
- DEFAULT_PARAM1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_PARAM2,
- g_param_spec_int ("param2", "param2 (aperture height)",
- "The aperture height, if zero, the width is used."
- "(Must be positive and odd or zero, unuset in median and bilateral "
- "types). Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
- "/documentation/image_filtering.html#cvSmooth", 0, G_MAXINT,
- DEFAULT_PARAM2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_PARAM3,
- g_param_spec_double ("param3", "param3 (gaussian standard deviation or "
- "color sigma",
- "If type is gaussian, this means the standard deviation."
- "If type is bilateral, this means the color-sigma. If zero, "
- "Default values are used."
- "Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
- "/documentation/image_filtering.html#cvSmooth",
- 0, G_MAXDOUBLE, DEFAULT_PARAM3,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_PARAM4,
- g_param_spec_double ("param4", "param4 (spatial sigma, bilateral only)",
- "Only used in bilateral type, means the spatial-sigma."
- "Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
- "/documentation/image_filtering.html#cvSmooth",
- 0, G_MAXDOUBLE, DEFAULT_PARAM4,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_cv_smooth_init (GstCvSmooth * filter, GstCvSmoothClass * gclass)
-{
- filter->type = DEFAULT_CV_SMOOTH_TYPE;
- filter->param1 = DEFAULT_PARAM1;
- filter->param2 = DEFAULT_PARAM2;
- filter->param3 = DEFAULT_PARAM3;
- filter->param4 = DEFAULT_PARAM4;
-
- gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
-}
-
-static void
-gst_cv_smooth_change_type (GstCvSmooth * filter, gint value)
-{
- GST_DEBUG_OBJECT (filter, "Changing type from %d to %d", filter->type, value);
- if (filter->type == value)
- return;
-
- filter->type = value;
- switch (value) {
- case CV_GAUSSIAN:
- case CV_BLUR:
- gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
- break;
- default:
- gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
- break;
- }
-}
-
-static void
-gst_cv_smooth_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstCvSmooth *filter = GST_CV_SMOOTH (object);
-
- switch (prop_id) {
- case PROP_SMOOTH_TYPE:
- gst_cv_smooth_change_type (filter, g_value_get_enum (value));
- break;
- case PROP_PARAM1:{
- gint prop = g_value_get_int (value);
-
- if (prop % 2 == 1) {
- filter->param1 = prop;
- } else {
- GST_WARNING_OBJECT (filter, "Ignoring value for param1, not odd"
- "(%d)", prop);
- }
- }
- break;
- case PROP_PARAM2:{
- gint prop = g_value_get_int (value);
-
- if (prop % 2 == 1 || prop == 0) {
- filter->param1 = prop;
- } else {
- GST_WARNING_OBJECT (filter, "Ignoring value for param2, not odd"
- " nor zero (%d)", prop);
- }
- }
- break;
- case PROP_PARAM3:
- filter->param3 = g_value_get_double (value);
- break;
- case PROP_PARAM4:
- filter->param4 = g_value_get_double (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_cv_smooth_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstCvSmooth *filter = GST_CV_SMOOTH (object);
-
- switch (prop_id) {
- case PROP_SMOOTH_TYPE:
- g_value_set_enum (value, filter->type);
- break;
- case PROP_PARAM1:
- g_value_set_int (value, filter->param1);
- break;
- case PROP_PARAM2:
- g_value_set_int (value, filter->param2);
- break;
- case PROP_PARAM3:
- g_value_set_double (value, filter->param3);
- break;
- case PROP_PARAM4:
- g_value_set_double (value, filter->param4);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstFlowReturn
-gst_cv_smooth_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img, GstBuffer * outbuf, IplImage * outimg)
-{
- GstCvSmooth *filter = GST_CV_SMOOTH (base);
-
- cvSmooth (img, outimg, filter->type, filter->param1, filter->param2,
- filter->param3, filter->param4);
-
- return GST_FLOW_OK;
-}
-
-static GstFlowReturn
-gst_cv_smooth_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img)
-{
- GstCvSmooth *filter = GST_CV_SMOOTH (base);
-
- cvSmooth (img, img, filter->type, filter->param1, filter->param2,
- filter->param3, filter->param4);
-
- return GST_FLOW_OK;
-}
-
-gboolean
-gst_cv_smooth_plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (gst_cv_smooth_debug, "cvsmooth", 0, "cvsmooth");
-
- return gst_element_register (plugin, "cvsmooth", GST_RANK_NONE,
- GST_TYPE_CV_SMOOTH);
-}
+++ /dev/null
-/*
- * 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_SMOOTH_H__
-#define __GST_CV_SMOOTH_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include <gstopencvvideofilter.h>
-
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_CV_SMOOTH \
- (gst_cv_smooth_get_type())
-#define GST_CV_SMOOTH(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_SMOOTH,GstCvSmooth))
-#define GST_CV_SMOOTH_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_SMOOTH,GstCvSmoothClass))
-#define GST_IS_CV_SMOOTH(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_SMOOTH))
-#define GST_IS_CV_SMOOTH_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_SMOOTH))
-
-typedef struct _GstCvSmooth GstCvSmooth;
-typedef struct _GstCvSmoothClass GstCvSmoothClass;
-
-struct _GstCvSmooth
-{
- GstOpencvVideoFilter element;
-
- gint type;
-
- gint param1;
- gint param2;
- gdouble param3;
- gdouble param4;
-};
-
-struct _GstCvSmoothClass
-{
- GstOpencvVideoFilterClass parent_class;
-};
-
-GType gst_cv_smooth_get_type (void);
-
-gboolean gst_cv_smooth_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_CV_SMOOTH_H__ */
+++ /dev/null
-/*
- * 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 "gstcvsobel.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_cv_sobel_debug);
-#define GST_CAT_DEFAULT gst_cv_sobel_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)16, bpp=(int)16, endianness=(int)4321")
- );
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-enum
-{
- PROP_0,
- PROP_X_ORDER,
- PROP_Y_ORDER,
- PROP_APERTURE_SIZE
-};
-
-#define DEFAULT_X_ORDER 1
-#define DEFAULT_Y_ORDER 0
-#define DEFAULT_APERTURE_SIZE 3
-
-GST_BOILERPLATE (GstCvSobel, gst_cv_sobel, GstOpencvVideoFilter,
- GST_TYPE_OPENCV_VIDEO_FILTER);
-
-static void gst_cv_sobel_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_cv_sobel_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstCaps *gst_cv_sobel_transform_caps (GstBaseTransform * trans,
- GstPadDirection dir, GstCaps * caps);
-
-static GstFlowReturn gst_cv_sobel_transform (GstOpencvVideoFilter * filter,
- GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
-
-/* Clean up */
-static void
-gst_cv_sobel_finalize (GObject * obj)
-{
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-/* GObject vmethod implementations */
-
-static void
-gst_cv_sobel_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,
- "cvsobel",
- "Transform/Effect/Video",
- "Applies cvSobel OpenCV function to the image",
- "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
-}
-
-/* initialize the cvsobel's class */
-static void
-gst_cv_sobel_class_init (GstCvSobelClass * klass)
-{
- GObjectClass *gobject_class;
- GstBaseTransformClass *gstbasetransform_class;
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstbasetransform_class = (GstBaseTransformClass *) klass;
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_sobel_finalize);
- gobject_class->set_property = gst_cv_sobel_set_property;
- gobject_class->get_property = gst_cv_sobel_get_property;
-
- gstbasetransform_class->transform_caps = gst_cv_sobel_transform_caps;
-
- gstopencvbasefilter_class->cv_trans_func = gst_cv_sobel_transform;
-
- g_object_class_install_property (gobject_class, PROP_X_ORDER,
- g_param_spec_int ("x-order", "x order",
- "Order of the derivative x", -1, G_MAXINT,
- DEFAULT_X_ORDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_Y_ORDER,
- g_param_spec_int ("y-order", "y order",
- "Order of the derivative y", -1, G_MAXINT,
- DEFAULT_Y_ORDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_APERTURE_SIZE,
- g_param_spec_int ("aperture-size", "aperture size",
- "Size of the extended Sobel Kernel (1, 3, 5 or 7)", 1, 7,
- DEFAULT_APERTURE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-}
-
-static void
-gst_cv_sobel_init (GstCvSobel * filter, GstCvSobelClass * gclass)
-{
- filter->x_order = DEFAULT_X_ORDER;
- filter->y_order = DEFAULT_Y_ORDER;
- filter->aperture_size = DEFAULT_APERTURE_SIZE;
-
- gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
-}
-
-static GstCaps *
-gst_cv_sobel_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
- GstCaps * caps)
-{
- GstCaps *output = NULL;
- GstStructure *structure;
- gint i;
-
- output = gst_caps_copy (caps);
-
- /* we accept anything from the template caps for either side */
- switch (dir) {
- case GST_PAD_SINK:
- for (i = 0; i < gst_caps_get_size (output); i++) {
- structure = gst_caps_get_structure (output, i);
- gst_structure_set (structure,
- "depth", G_TYPE_INT, 16,
- "bpp", G_TYPE_INT, 16, "endianness", G_TYPE_INT, 4321, NULL);
- }
- break;
- case GST_PAD_SRC:
- for (i = 0; i < gst_caps_get_size (output); i++) {
- structure = gst_caps_get_structure (output, i);
- gst_structure_set (structure,
- "depth", G_TYPE_INT, 8, "bpp", G_TYPE_INT, 8, NULL);
- gst_structure_remove_field (structure, "endianness");
- }
- break;
- default:
- gst_caps_unref (output);
- output = NULL;
- g_assert_not_reached ();
- break;
- }
-
- return output;
-}
-
-static void
-gst_cv_sobel_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstCvSobel *filter = GST_CV_SOBEL (object);
-
- switch (prop_id) {
- case PROP_X_ORDER:
- filter->x_order = g_value_get_int (value);
- break;
- case PROP_Y_ORDER:
- filter->y_order = g_value_get_int (value);
- break;
- case PROP_APERTURE_SIZE:{
- gint as = g_value_get_int (value);
-
- if (as % 2 != 1) {
- GST_WARNING_OBJECT (filter, "Invalid value %d for aperture size", as);
- } else
- filter->aperture_size = g_value_get_int (value);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_cv_sobel_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstCvSobel *filter = GST_CV_SOBEL (object);
-
- switch (prop_id) {
- case PROP_X_ORDER:
- g_value_set_int (value, filter->x_order);
- break;
- case PROP_Y_ORDER:
- g_value_set_int (value, filter->y_order);
- break;
- case PROP_APERTURE_SIZE:
- g_value_set_int (value, filter->aperture_size);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstFlowReturn
-gst_cv_sobel_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img, GstBuffer * outbuf, IplImage * outimg)
-{
- GstCvSobel *filter = GST_CV_SOBEL (base);
-
- cvSobel (img, outimg, filter->x_order, filter->y_order,
- filter->aperture_size);
-
- return GST_FLOW_OK;
-}
-
-gboolean
-gst_cv_sobel_plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (gst_cv_sobel_debug, "cvsobel", 0, "cvsobel");
-
- return gst_element_register (plugin, "cvsobel", GST_RANK_NONE,
- GST_TYPE_CV_SOBEL);
-}
+++ /dev/null
-/*
- * 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_SOBEL_H__
-#define __GST_CV_SOBEL_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include <gstopencvvideofilter.h>
-
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_CV_SOBEL \
- (gst_cv_sobel_get_type())
-#define GST_CV_SOBEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_SOBEL,GstCvSobel))
-#define GST_CV_SOBEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_SOBEL,GstCvSobelClass))
-#define GST_IS_CV_SOBEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_SOBEL))
-#define GST_IS_CV_SOBEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_SOBEL))
-
-typedef struct _GstCvSobel GstCvSobel;
-typedef struct _GstCvSobelClass GstCvSobelClass;
-
-struct _GstCvSobel
-{
- GstOpencvVideoFilter element;
-
- gint x_order;
- gint y_order;
- gint aperture_size;
-};
-
-struct _GstCvSobelClass
-{
- GstOpencvVideoFilterClass parent_class;
-};
-
-GType gst_cv_sobel_get_type (void);
-
-gboolean gst_cv_sobel_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_CV_SOBEL_H__ */
+++ /dev/null
-# plugindir is set in configure
-
-noinst_LTLIBRARIES = libgstedgedetect.la
-
-# sources used to compile this plug-in
-libgstedgedetect_la_SOURCES = gstedgedetect.c
-
-# flags used to compile this edgedetect
-# add other _CFLAGS and _LIBS as needed
-libgstedgedetect_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS)
-libgstedgedetect_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
-libgstedgedetect_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gstedgedetect.h
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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.
- */
-
-/**
- * SECTION:element-edgedetect
- *
- * FIXME:Describe edgedetect here.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! edgedetect ! ffmpegcolorspace ! xvimagesink
- * ]|
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gstedgedetect.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_edgedetect_debug);
-#define GST_CAT_DEFAULT gst_edgedetect_debug
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_THRESHOLD1,
- PROP_THRESHOLD2,
- PROP_APERTURE,
- PROP_MASK
-};
-
-/* the capabilities of the inputs and outputs.
- *
- * describe the real formats here.
- */
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-GST_BOILERPLATE (Gstedgedetect, gst_edgedetect, GstElement, GST_TYPE_ELEMENT);
-
-static void gst_edgedetect_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_edgedetect_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_edgedetect_set_caps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_edgedetect_chain (GstPad * pad, GstBuffer * buf);
-
-/* Clean up */
-static void
-gst_edgedetect_finalize (GObject * obj)
-{
- Gstedgedetect *filter = GST_EDGEDETECT (obj);
-
- if (filter->cvImage != NULL) {
- cvReleaseImage (&filter->cvImage);
- cvReleaseImage (&filter->cvCEdge);
- cvReleaseImage (&filter->cvGray);
- cvReleaseImage (&filter->cvEdge);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-/* GObject vmethod implementations */
-static void
-gst_edgedetect_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "edgedetect",
- "Filter/Effect/Video",
- "Performs canny edge detection on videos and images.",
- "Michael Sheldon <mike@mikeasoft.com>");
-
- 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));
-}
-
-/* initialize the edgedetect's class */
-static void
-gst_edgedetect_class_init (GstedgedetectClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_edgedetect_finalize);
- gobject_class->set_property = gst_edgedetect_set_property;
- gobject_class->get_property = gst_edgedetect_get_property;
-
- g_object_class_install_property (gobject_class, PROP_MASK,
- g_param_spec_boolean ("mask", "Mask",
- "Sets whether the detected edges should be used as a mask on the original input or not",
- TRUE, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_THRESHOLD1,
- g_param_spec_int ("threshold1", "Threshold1",
- "Threshold value for canny edge detection", 0, 1000, 50,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_THRESHOLD2,
- g_param_spec_int ("threshold2", "Threshold2",
- "Second threshold value for canny edge detection", 0, 1000, 150,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_APERTURE,
- g_param_spec_int ("aperture", "Aperture",
- "Aperture size for Sobel operator (Must be either 3, 5 or 7", 3, 7, 3,
- G_PARAM_READWRITE));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_edgedetect_init (Gstedgedetect * filter, GstedgedetectClass * gclass)
-{
- filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_edgedetect_set_caps));
- gst_pad_set_getcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
- gst_pad_set_chain_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_edgedetect_chain));
-
- filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_pad_set_getcaps_function (filter->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
-
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- filter->mask = TRUE;
- filter->threshold1 = 50;
- filter->threshold2 = 150;
- filter->aperture = 3;
-}
-
-static void
-gst_edgedetect_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- Gstedgedetect *filter = GST_EDGEDETECT (object);
-
- switch (prop_id) {
- case PROP_MASK:
- filter->mask = g_value_get_boolean (value);
- break;
- case PROP_THRESHOLD1:
- filter->threshold1 = g_value_get_int (value);
- break;
- case PROP_THRESHOLD2:
- filter->threshold2 = g_value_get_int (value);
- break;
- case PROP_APERTURE:
- filter->aperture = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_edgedetect_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- Gstedgedetect *filter = GST_EDGEDETECT (object);
-
- switch (prop_id) {
- case PROP_MASK:
- g_value_set_boolean (value, filter->mask);
- break;
- case PROP_THRESHOLD1:
- g_value_set_int (value, filter->threshold1);
- break;
- case PROP_THRESHOLD2:
- g_value_set_int (value, filter->threshold2);
- break;
- case PROP_APERTURE:
- g_value_set_int (value, filter->aperture);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* GstElement vmethod implementations */
-
-/* this function handles the link with other elements */
-static gboolean
-gst_edgedetect_set_caps (GstPad * pad, GstCaps * caps)
-{
- Gstedgedetect *filter;
- GstPad *otherpad;
- gint width, height;
- GstStructure *structure;
-
- filter = GST_EDGEDETECT (gst_pad_get_parent (pad));
- structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
- filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
- filter->cvCEdge = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
- filter->cvGray = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
- filter->cvEdge = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
-
- otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
- gst_object_unref (filter);
-
- return gst_pad_set_caps (otherpad, caps);
-}
-
-/* chain function
- * this function does the actual processing
- */
-static GstFlowReturn
-gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
-{
- Gstedgedetect *filter;
- GstBuffer *outbuf;
-
- filter = GST_EDGEDETECT (GST_OBJECT_PARENT (pad));
-
- filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
-
- cvCvtColor (filter->cvImage, filter->cvGray, CV_RGB2GRAY);
- cvSmooth (filter->cvGray, filter->cvEdge, CV_BLUR, 3, 3, 0, 0);
- cvNot (filter->cvGray, filter->cvEdge);
- cvCanny (filter->cvGray, filter->cvEdge, filter->threshold1,
- filter->threshold2, filter->aperture);
-
- cvZero (filter->cvCEdge);
- if (filter->mask) {
- cvCopy (filter->cvImage, filter->cvCEdge, filter->cvEdge);
- } else {
- cvCvtColor (filter->cvEdge, filter->cvCEdge, CV_GRAY2RGB);
- }
-
- outbuf = gst_buffer_new_and_alloc (filter->cvCEdge->imageSize);
- gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_ALL);
- memcpy (GST_BUFFER_DATA (outbuf), filter->cvCEdge->imageData,
- GST_BUFFER_SIZE (outbuf));
-
- gst_buffer_unref (buf);
- return gst_pad_push (filter->srcpad, outbuf);
-}
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_edgedetect_plugin_init (GstPlugin * plugin)
-{
- /* debug category for fltering log messages
- *
- * exchange the string 'Template edgedetect' with your description
- */
- GST_DEBUG_CATEGORY_INIT (gst_edgedetect_debug, "edgedetect",
- 0, "Performs canny edge detection on videos and images");
-
- return gst_element_register (plugin, "edgedetect", GST_RANK_NONE,
- GST_TYPE_EDGEDETECT);
-}
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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_EDGEDETECT_H__
-#define __GST_EDGEDETECT_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-
-G_BEGIN_DECLS
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_EDGEDETECT \
- (gst_edgedetect_get_type())
-#define GST_EDGEDETECT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EDGEDETECT,Gstedgedetect))
-#define GST_EDGEDETECT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EDGEDETECT,GstedgedetectClass))
-#define GST_IS_EDGEDETECT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EDGEDETECT))
-#define GST_IS_EDGEDETECT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EDGEDETECT))
-typedef struct _Gstedgedetect Gstedgedetect;
-typedef struct _GstedgedetectClass GstedgedetectClass;
-
-struct _Gstedgedetect
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
- gboolean mask;
-
- int threshold1, threshold2, aperture;
-
- IplImage *cvEdge, *cvGray, *cvImage, *cvCEdge;
-};
-
-struct _GstedgedetectClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_edgedetect_get_type (void);
-
-gboolean gst_edgedetect_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-#endif /* __GST_EDGEDETECT_H__ */
+++ /dev/null
-# plugindir is set in configure
-
-noinst_LTLIBRARIES = libgstfaceblur.la
-
-# sources used to compile this plug-in
-libgstfaceblur_la_SOURCES = gstfaceblur.c
-
-# flags used to compile this faceblur
-# add other _CFLAGS and _LIBS as needed
-libgstfaceblur_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS)
-libgstfaceblur_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
-libgstfaceblur_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gstfaceblur.h
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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.
- */
-
-/**
- * SECTION:element-faceblur
- *
- * FIXME:Describe faceblur here.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! faceblur ! ffmpegcolorspace ! xvimagesink
- * ]|
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gstfaceblur.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_faceblur_debug);
-#define GST_CAT_DEFAULT gst_faceblur_debug
-
-#define DEFAULT_PROFILE "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml"
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_PROFILE
-};
-
-/* the capabilities of the inputs and outputs.
- */
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-GST_BOILERPLATE (Gstfaceblur, gst_faceblur, GstElement, GST_TYPE_ELEMENT);
-
-static void gst_faceblur_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_faceblur_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_faceblur_set_caps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_faceblur_chain (GstPad * pad, GstBuffer * buf);
-
-static void gst_faceblur_load_profile (Gstfaceblur * filter);
-
-/* Clean up */
-static void
-gst_faceblur_finalize (GObject * obj)
-{
- Gstfaceblur *filter = GST_FACEBLUR (obj);
-
- if (filter->cvImage) {
- cvReleaseImage (&filter->cvImage);
- cvReleaseImage (&filter->cvGray);
- }
-
- g_free (filter->profile);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-
-/* GObject vmethod implementations */
-static void
-gst_faceblur_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "faceblur",
- "Filter/Effect/Video",
- "Blurs faces in images and videos",
- "Michael Sheldon <mike@mikeasoft.com>");
-
- 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));
-}
-
-/* initialize the faceblur's class */
-static void
-gst_faceblur_class_init (GstfaceblurClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_faceblur_finalize);
- gobject_class->set_property = gst_faceblur_set_property;
- gobject_class->get_property = gst_faceblur_get_property;
-
- g_object_class_install_property (gobject_class, PROP_PROFILE,
- g_param_spec_string ("profile", "Profile",
- "Location of Haar cascade file to use for face blurion",
- DEFAULT_PROFILE, G_PARAM_READWRITE));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_faceblur_init (Gstfaceblur * filter, GstfaceblurClass * gclass)
-{
- filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_faceblur_set_caps));
- gst_pad_set_getcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
- gst_pad_set_chain_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_faceblur_chain));
-
- filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_pad_set_getcaps_function (filter->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
-
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- filter->profile = g_strdup (DEFAULT_PROFILE);
- gst_faceblur_load_profile (filter);
-}
-
-static void
-gst_faceblur_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- Gstfaceblur *filter = GST_FACEBLUR (object);
-
- switch (prop_id) {
- case PROP_PROFILE:
- g_free (filter->profile);
- filter->profile = g_value_dup_string (value);
- gst_faceblur_load_profile (filter);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_faceblur_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- Gstfaceblur *filter = GST_FACEBLUR (object);
-
- switch (prop_id) {
- case PROP_PROFILE:
- g_value_set_string (value, filter->profile);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* GstElement vmethod implementations */
-
-/* this function handles the link with other elements */
-static gboolean
-gst_faceblur_set_caps (GstPad * pad, GstCaps * caps)
-{
- Gstfaceblur *filter;
- GstPad *otherpad;
- gint width, height;
- GstStructure *structure;
-
- filter = GST_FACEBLUR (gst_pad_get_parent (pad));
- structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
- filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
- filter->cvGray = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
- filter->cvStorage = cvCreateMemStorage (0);
-
- otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
- gst_object_unref (filter);
-
- return gst_pad_set_caps (otherpad, caps);
-}
-
-/* chain function
- * this function does the actual processing
- */
-static GstFlowReturn
-gst_faceblur_chain (GstPad * pad, GstBuffer * buf)
-{
- Gstfaceblur *filter;
- CvSeq *faces;
- int i;
-
- filter = GST_FACEBLUR (GST_OBJECT_PARENT (pad));
-
- filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
-
- cvCvtColor (filter->cvImage, filter->cvGray, CV_RGB2GRAY);
- cvClearMemStorage (filter->cvStorage);
-
- if (filter->cvCascade) {
- faces =
- cvHaarDetectObjects (filter->cvGray, filter->cvCascade,
- filter->cvStorage, 1.1, 2, 0, cvSize (30, 30));
-
- if (faces && faces->total > 0) {
- buf = gst_buffer_make_writable (buf);
- }
- for (i = 0; i < (faces ? faces->total : 0); i++) {
- CvRect *r = (CvRect *) cvGetSeqElem (faces, i);
- cvSetImageROI (filter->cvImage, *r);
- cvSmooth (filter->cvImage, filter->cvImage, CV_BLUR, 11, 11, 0, 0);
- cvSmooth (filter->cvImage, filter->cvImage, CV_GAUSSIAN, 11, 11, 0, 0);
- cvResetImageROI (filter->cvImage);
- }
- }
-
- /* these filters operate in place, so we push the same buffer */
-
- return gst_pad_push (filter->srcpad, buf);
-}
-
-
-static void
-gst_faceblur_load_profile (Gstfaceblur * filter)
-{
- filter->cvCascade =
- (CvHaarClassifierCascade *) cvLoad (filter->profile, 0, 0, 0);
- if (!filter->cvCascade) {
- GST_WARNING ("Couldn't load Haar classifier cascade: %s.", filter->profile);
- }
-}
-
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_faceblur_plugin_init (GstPlugin * plugin)
-{
- /* debug category for filtering log messages */
- GST_DEBUG_CATEGORY_INIT (gst_faceblur_debug, "faceblur",
- 0, "Blurs faces in images and videos");
-
- return gst_element_register (plugin, "faceblur", GST_RANK_NONE,
- GST_TYPE_FACEBLUR);
-}
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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_FACEBLUR_H__
-#define __GST_FACEBLUR_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-
-G_BEGIN_DECLS
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_FACEBLUR \
- (gst_faceblur_get_type())
-#define GST_FACEBLUR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FACEBLUR,Gstfaceblur))
-#define GST_FACEBLUR_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FACEBLUR,GstfaceblurClass))
-#define GST_IS_FACEBLUR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FACEBLUR))
-#define GST_IS_FACEBLUR_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FACEBLUR))
-typedef struct _Gstfaceblur Gstfaceblur;
-typedef struct _GstfaceblurClass GstfaceblurClass;
-
-struct _Gstfaceblur
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
- gboolean display;
-
- gchar *profile;
-
- IplImage *cvImage, *cvGray;
- CvHaarClassifierCascade *cvCascade;
- CvMemStorage *cvStorage;
-};
-
-struct _GstfaceblurClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_faceblur_get_type (void);
-
-gboolean gst_faceblur_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-#endif /* __GST_FACEBLUR_H__ */
+++ /dev/null
-# plugindir is set in configure
-
-noinst_LTLIBRARIES = libgstfacedetect.la
-
-# sources used to compile this plug-in
-libgstfacedetect_la_SOURCES = gstfacedetect.c
-
-# flags used to compile this facedetect
-# add other _CFLAGS and _LIBS as needed
-libgstfacedetect_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS) \
- $(GSTPB_BASE_CFLAGS) -I..
-libgstfacedetect_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS) $(GSTPB_BASE_LIBS) \
- -lgstvideo-$(GST_MAJORMINOR)
-libgstfacedetect_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gstfacedetect.h
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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.
- */
-
-/**
- * SECTION:element-facedetect
- *
- * FIXME:Describe facedetect here.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! facedetect ! ffmpegcolorspace ! xvimagesink
- * ]|
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gstfacedetect.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_facedetect_debug);
-#define GST_CAT_DEFAULT gst_facedetect_debug
-
-#define DEFAULT_PROFILE "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml"
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_DISPLAY,
- PROP_PROFILE
-};
-
-/* the capabilities of the inputs and outputs.
- */
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-GST_BOILERPLATE (Gstfacedetect, gst_facedetect, GstOpencvVideoFilter,
- GST_TYPE_OPENCV_VIDEO_FILTER);
-
-static void gst_facedetect_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_facedetect_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_facedetect_set_caps (GstOpencvVideoFilter * transform,
- gint in_width, gint in_height, gint in_depth, gint in_channels,
- gint out_width, gint out_height, gint out_depth, gint out_channels);
-static GstFlowReturn gst_facedetect_transform_ip (GstOpencvVideoFilter * base,
- GstBuffer * buf, IplImage * img);
-
-static void gst_facedetect_load_profile (Gstfacedetect * filter);
-
-/* Clean up */
-static void
-gst_facedetect_finalize (GObject * obj)
-{
- Gstfacedetect *filter = GST_FACEDETECT (obj);
-
- if (filter->cvGray) {
- cvReleaseImage (&filter->cvGray);
- }
- if (filter->cvStorage) {
- cvReleaseMemStorage (&filter->cvStorage);
- }
-
- g_free (filter->profile);
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-
-/* GObject vmethod implementations */
-static void
-gst_facedetect_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "facedetect",
- "Filter/Effect/Video",
- "Performs face detection on videos and images, providing detected positions via bus messages",
- "Michael Sheldon <mike@mikeasoft.com>");
-
- 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));
-}
-
-/* initialize the facedetect's class */
-static void
-gst_facedetect_class_init (GstfacedetectClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
- GstOpencvVideoFilterClass *gstopencvbasefilter_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_facedetect_finalize);
- gobject_class->set_property = gst_facedetect_set_property;
- gobject_class->get_property = gst_facedetect_get_property;
-
- gstopencvbasefilter_class->cv_trans_ip_func = gst_facedetect_transform_ip;
- gstopencvbasefilter_class->cv_set_caps = gst_facedetect_set_caps;
-
- g_object_class_install_property (gobject_class, PROP_DISPLAY,
- g_param_spec_boolean ("display", "Display",
- "Sets whether the detected faces should be highlighted in the output",
- TRUE, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_PROFILE,
- g_param_spec_string ("profile", "Profile",
- "Location of Haar cascade file to use for face detection",
- DEFAULT_PROFILE, G_PARAM_READWRITE));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_facedetect_init (Gstfacedetect * filter, GstfacedetectClass * gclass)
-{
- filter->profile = g_strdup(DEFAULT_PROFILE);
- filter->display = TRUE;
- gst_facedetect_load_profile (filter);
-
- gst_opencv_video_filter_set_in_place (GST_OPENCV_VIDEO_FILTER_CAST (filter),
- TRUE);
-}
-
-static void
-gst_facedetect_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- Gstfacedetect *filter = GST_FACEDETECT (object);
-
- switch (prop_id) {
- case PROP_PROFILE:
- g_free (filter->profile);
- filter->profile = g_value_dup_string (value);
- gst_facedetect_load_profile (filter);
- break;
- case PROP_DISPLAY:
- filter->display = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_facedetect_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- Gstfacedetect *filter = GST_FACEDETECT (object);
-
- switch (prop_id) {
- case PROP_PROFILE:
- g_value_set_string (value, filter->profile);
- break;
- case PROP_DISPLAY:
- g_value_set_boolean (value, filter->display);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* GstElement vmethod implementations */
-
-/* this function handles the link with other elements */
-static gboolean
-gst_facedetect_set_caps (GstOpencvVideoFilter * transform, gint in_width,
- gint in_height, gint in_depth, gint in_channels,
- gint out_width, gint out_height, gint out_depth, gint out_channels)
-{
- Gstfacedetect *filter;
-
- filter = GST_FACEDETECT (transform);
-
- if (filter->cvGray)
- cvReleaseImage (&filter->cvGray);
-
- filter->cvGray = cvCreateImage (cvSize (in_width, in_height), IPL_DEPTH_8U,
- 1);
-
- if (!filter->cvStorage)
- filter->cvStorage = cvCreateMemStorage (0);
- else
- cvClearMemStorage (filter->cvStorage);
-
- return TRUE;
-}
-
-static GstMessage *
-gst_facedetect_message_new (Gstfacedetect * filter, GstBuffer * buf)
-{
- GstBaseTransform *trans = GST_BASE_TRANSFORM_CAST (filter);
- GstStructure *s;
- GstClockTime running_time, stream_time;
-
- running_time = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME,
- GST_BUFFER_TIMESTAMP (buf));
- stream_time = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
- GST_BUFFER_TIMESTAMP (buf));
-
- s = gst_structure_new ("facedetect",
- "timestamp", G_TYPE_UINT64, GST_BUFFER_TIMESTAMP (buf),
- "stream-time", G_TYPE_UINT64, stream_time,
- "running-time", G_TYPE_UINT64, running_time,
- "duration", G_TYPE_UINT64, GST_BUFFER_DURATION (buf), NULL);
-
- return gst_message_new_element (GST_OBJECT (filter), s);
-}
-
-
-/* chain function
- * this function does the actual processing
- */
-static GstFlowReturn
-gst_facedetect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img)
-{
- Gstfacedetect *filter;
- CvSeq *faces;
- int i;
-
- filter = GST_FACEDETECT (base);
-
- cvCvtColor (img, filter->cvGray, CV_RGB2GRAY);
- cvClearMemStorage (filter->cvStorage);
-
- if (filter->cvCascade) {
- GstMessage *msg = NULL;
- GValue facelist = { 0 };
-
- faces =
- cvHaarDetectObjects (filter->cvGray, filter->cvCascade,
- filter->cvStorage, 1.1, 2, 0, cvSize (30, 30));
-
- if (faces && faces->total > 0) {
- msg = gst_facedetect_message_new (filter, buf);
- g_value_init (&facelist, GST_TYPE_LIST);
- }
-
- for (i = 0; i < (faces ? faces->total : 0); i++) {
- CvRect *r = (CvRect *) cvGetSeqElem (faces, i);
- GValue value = { 0 };
-
- GstStructure *s = gst_structure_new ("face",
- "x", G_TYPE_UINT, r->x,
- "y", G_TYPE_UINT, r->y,
- "width", G_TYPE_UINT, r->width,
- "height", G_TYPE_UINT, r->height, NULL);
-
- GstMessage *m = gst_message_new_element (GST_OBJECT (filter), s);
-
- g_value_init (&value, GST_TYPE_STRUCTURE);
- gst_value_set_structure (&value, s);
- gst_value_list_append_value (&facelist, &value);
- g_value_unset (&value);
-
- gst_element_post_message (GST_ELEMENT (filter), m);
-
- if (filter->display) {
- if (gst_buffer_is_writable (buf)) {
- CvPoint center;
- int radius;
- center.x = cvRound ((r->x + r->width * 0.5));
- center.y = cvRound ((r->y + r->height * 0.5));
- radius = cvRound ((r->width + r->height) * 0.25);
- cvCircle (img, center, radius, CV_RGB (255, 32, 32), 3, 8, 0);
- } else {
- GST_DEBUG_OBJECT (filter, "Buffer is not writable, not drawing "
- "circles for faces");
- }
- }
-
- }
-
- if (msg) {
- gst_structure_set_value (msg->structure, "faces", &facelist);
- g_value_unset (&facelist);
- gst_element_post_message (GST_ELEMENT (filter), msg);
- }
- }
-
- return GST_FLOW_OK;
-}
-
-
-static void
-gst_facedetect_load_profile (Gstfacedetect * filter)
-{
- filter->cvCascade =
- (CvHaarClassifierCascade *) cvLoad (filter->profile, 0, 0, 0);
- if (!filter->cvCascade) {
- GST_WARNING ("Couldn't load Haar classifier cascade: %s.", filter->profile);
- }
-}
-
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_facedetect_plugin_init (GstPlugin * plugin)
-{
- /* debug category for fltering log messages */
- GST_DEBUG_CATEGORY_INIT (gst_facedetect_debug, "facedetect",
- 0,
- "Performs face detection on videos and images, providing detected positions via bus messages");
-
- return gst_element_register (plugin, "facedetect", GST_RANK_NONE,
- GST_TYPE_FACEDETECT);
-}
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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_FACEDETECT_H__
-#define __GST_FACEDETECT_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include "gstopencvvideofilter.h"
-
-G_BEGIN_DECLS
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_FACEDETECT \
- (gst_facedetect_get_type())
-#define GST_FACEDETECT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FACEDETECT,Gstfacedetect))
-#define GST_FACEDETECT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FACEDETECT,GstfacedetectClass))
-#define GST_IS_FACEDETECT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FACEDETECT))
-#define GST_IS_FACEDETECT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FACEDETECT))
-typedef struct _Gstfacedetect Gstfacedetect;
-typedef struct _GstfacedetectClass GstfacedetectClass;
-
-struct _Gstfacedetect
-{
- GstOpencvVideoFilter element;
-
- gboolean display;
-
- gchar *profile;
-
- IplImage *cvGray;
- CvHaarClassifierCascade *cvCascade;
- CvMemStorage *cvStorage;
-};
-
-struct _GstfacedetectClass
-{
- GstOpencvVideoFilterClass parent_class;
-};
-
-GType gst_facedetect_get_type (void);
-
-gboolean gst_facedetect_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-#endif /* __GST_FACEDETECT_H__ */
--- /dev/null
+/*
+ * 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 "gstcvdilate.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_cv_dilate_debug);
+#define GST_CAT_DEFAULT gst_cv_dilate_debug
+
+GST_BOILERPLATE (GstCvDilate, gst_cv_dilate, GstCvDilateErode,
+ GST_TYPE_CV_DILATE_ERODE);
+
+static GstFlowReturn gst_cv_dilate_transform_ip (GstOpencvVideoFilter *
+ filter, GstBuffer * buf, IplImage * img);
+static GstFlowReturn gst_cv_dilate_transform (GstOpencvVideoFilter * filter,
+ GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
+
+/* GObject vmethod implementations */
+static void
+gst_cv_dilate_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "cvdilate",
+ "Transform/Effect/Video",
+ "Applies cvDilate OpenCV function to the image",
+ "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
+}
+
+/* initialize the cvdilate's class */
+static void
+gst_cv_dilate_class_init (GstCvDilateClass * klass)
+{
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_dilate_transform_ip;
+ gstopencvbasefilter_class->cv_trans_func = gst_cv_dilate_transform;
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_cv_dilate_init (GstCvDilate * filter, GstCvDilateClass * gclass)
+{
+}
+
+static GstFlowReturn
+gst_cv_dilate_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img, GstBuffer * outbuf, IplImage * outimg)
+{
+ GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
+
+ /* TODO support kernel as a parameter */
+ cvDilate (img, outimg, NULL, filter->iterations);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_cv_dilate_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img)
+{
+ GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
+
+ cvDilate (img, img, NULL, filter->iterations);
+
+ return GST_FLOW_OK;
+}
+
+gboolean
+gst_cv_dilate_plugin_init (GstPlugin * plugin)
+{
+ GST_DEBUG_CATEGORY_INIT (gst_cv_dilate_debug, "cvdilate", 0, "cvdilate");
+
+ return gst_element_register (plugin, "cvdilate", GST_RANK_NONE,
+ GST_TYPE_CV_DILATE);
+}
--- /dev/null
+/*
+ * 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_DILATE_H__
+#define __GST_CV_DILATE_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include "gstcvdilateerode.h"
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CV_DILATE \
+ (gst_cv_dilate_get_type())
+#define GST_CV_DILATE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_DILATE,GstCvDilate))
+#define GST_CV_DILATE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_DILATE,GstCvDilateClass))
+#define GST_IS_CV_DILATE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_DILATE))
+#define GST_IS_CV_DILATE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_DILATE))
+
+typedef struct _GstCvDilate GstCvDilate;
+typedef struct _GstCvDilateClass GstCvDilateClass;
+
+struct _GstCvDilate
+{
+ GstCvDilateErode element;
+};
+
+struct _GstCvDilateClass
+{
+ GstCvDilateErodeClass parent_class;
+};
+
+GType gst_cv_dilate_get_type (void);
+
+gboolean gst_cv_dilate_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_CV_DILATE_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+/*
+ * As cvdilate_erode and cverode are all the same, except for the transform function,
+ * we hope this base class should keep maintenance easier.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gstcvdilateerode.h"
+
+/*
+GST_DEBUG_CATEGORY_STATIC (gst_cv_dilate_erode_debug);
+#define GST_CAT_DEFAULT gst_cv_dilate_erode_debug
+*/
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
+ "video/x-raw-gray")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
+ "video/x-raw-gray")
+ );
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+enum
+{
+ PROP_0,
+ PROP_ITERATIONS,
+};
+
+#define DEFAULT_ITERATIONS 1
+
+static GstElementClass *parent_class = NULL;
+
+static void gst_cv_dilate_erode_base_init (gpointer gclass);
+static void gst_cv_dilate_erode_class_init (GstCvDilateErodeClass * klass);
+static void gst_cv_dilate_erode_init (GstCvDilateErode * filter,
+ GstCvDilateErodeClass * gclass);
+
+static void gst_cv_dilate_erode_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cv_dilate_erode_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+GType
+gst_cv_dilate_erode_get_type (void)
+{
+ static volatile gsize opencv_dilate_erode_type = 0;
+
+ if (g_once_init_enter (&opencv_dilate_erode_type)) {
+ GType _type;
+ static const GTypeInfo opencv_dilate_erode_info = {
+ sizeof (GstCvDilateErodeClass),
+ (GBaseInitFunc) gst_cv_dilate_erode_base_init,
+ NULL,
+ (GClassInitFunc) gst_cv_dilate_erode_class_init,
+ NULL,
+ NULL,
+ sizeof (GstCvDilateErode),
+ 0,
+ (GInstanceInitFunc) gst_cv_dilate_erode_init,
+ };
+
+ _type = g_type_register_static (GST_TYPE_OPENCV_VIDEO_FILTER,
+ "GstCvDilateErode", &opencv_dilate_erode_info, G_TYPE_FLAG_ABSTRACT);
+/*
+ GST_DEBUG_CATEGORY_INIT (gst_cv_dilate_erode_debug, "cvdilateerode", 0,
+ "cvdilateerode");
+*/
+ g_once_init_leave (&opencv_dilate_erode_type, _type);
+ }
+ return opencv_dilate_erode_type;
+}
+
+/* Clean up */
+static void
+gst_cv_dilate_erode_finalize (GObject * obj)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+
+/* GObject vmethod implementations */
+
+static void
+gst_cv_dilate_erode_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));
+}
+
+/* initialize the cvdilate_erode's class */
+static void
+gst_cv_dilate_erode_class_init (GstCvDilateErodeClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_dilate_erode_finalize);
+ gobject_class->set_property = gst_cv_dilate_erode_set_property;
+ gobject_class->get_property = gst_cv_dilate_erode_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_ITERATIONS,
+ g_param_spec_int ("iterations", "iterations",
+ "Number of iterations to run the algorithm", 1, G_MAXINT,
+ DEFAULT_ITERATIONS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_cv_dilate_erode_init (GstCvDilateErode * filter,
+ GstCvDilateErodeClass * gclass)
+{
+ filter->iterations = DEFAULT_ITERATIONS;
+ gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
+}
+
+static void
+gst_cv_dilate_erode_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCvDilateErode *filter = GST_CV_DILATE_ERODE (object);
+
+ switch (prop_id) {
+ case PROP_ITERATIONS:
+ filter->iterations = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_cv_dilate_erode_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCvDilateErode *filter = GST_CV_DILATE_ERODE (object);
+
+ switch (prop_id) {
+ case PROP_ITERATIONS:
+ g_value_set_int (value, filter->iterations);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
--- /dev/null
+/*
+ * 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_DILATE_ERODE_H__
+#define __GST_CV_DILATE_ERODE_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include <gstopencvvideofilter.h>
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CV_DILATE_ERODE \
+ (gst_cv_dilate_erode_get_type())
+#define GST_CV_DILATE_ERODE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_DILATE_ERODE,GstCvDilateErode))
+#define GST_CV_DILATE_ERODE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_DILATE_ERODE,GstCvDilateErodeClass))
+#define GST_IS_CV_DILATE_ERODE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_DILATE_ERODE))
+#define GST_IS_CV_DILATE_ERODE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_DILATE_ERODE))
+
+typedef struct _GstCvDilateErode GstCvDilateErode;
+typedef struct _GstCvDilateErodeClass GstCvDilateErodeClass;
+
+struct _GstCvDilateErode
+{
+ GstOpencvVideoFilter element;
+
+ gint iterations;
+};
+
+struct _GstCvDilateErodeClass
+{
+ GstOpencvVideoFilterClass parent_class;
+};
+
+GType gst_cv_dilate_erode_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_CV_DILATE_ERODE_H__ */
--- /dev/null
+/*
+ * 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,
+ GstOpencvVideoFilter, GST_TYPE_OPENCV_VIDEO_FILTER);
+
+static GstFlowReturn gst_cv_equalize_hist_transform (GstOpencvVideoFilter *
+ 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;
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) 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 (GstOpencvVideoFilter * 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);
+}
--- /dev/null
+/*
+ * 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 <gstopencvvideofilter.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
+{
+ GstOpencvVideoFilter element;
+};
+
+struct _GstCvEqualizeHistClass
+{
+ GstOpencvVideoFilterClass 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__ */
--- /dev/null
+/*
+ * 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 "gstcverode.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_cv_erode_debug);
+#define GST_CAT_DEFAULT gst_cv_erode_debug
+
+GST_BOILERPLATE (GstCvErode, gst_cv_erode, GstCvDilateErode,
+ GST_TYPE_CV_DILATE_ERODE);
+
+static GstFlowReturn gst_cv_erode_transform_ip (GstOpencvVideoFilter *
+ filter, GstBuffer * buf, IplImage * img);
+static GstFlowReturn gst_cv_erode_transform (GstOpencvVideoFilter * filter,
+ GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
+
+/* GObject vmethod implementations */
+static void
+gst_cv_erode_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "cverode",
+ "Transform/Effect/Video",
+ "Applies cvErode OpenCV function to the image",
+ "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
+}
+
+/* initialize the cverode's class */
+static void
+gst_cv_erode_class_init (GstCvErodeClass * klass)
+{
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_erode_transform_ip;
+ gstopencvbasefilter_class->cv_trans_func = gst_cv_erode_transform;
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_cv_erode_init (GstCvErode * filter, GstCvErodeClass * gclass)
+{
+}
+
+static GstFlowReturn
+gst_cv_erode_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img, GstBuffer * outbuf, IplImage * outimg)
+{
+ GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
+
+ /* TODO support kernel as a parameter */
+ cvErode (img, outimg, NULL, filter->iterations);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_cv_erode_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img)
+{
+ GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
+
+ cvErode (img, img, NULL, filter->iterations);
+
+ return GST_FLOW_OK;
+}
+
+gboolean
+gst_cv_erode_plugin_init (GstPlugin * plugin)
+{
+ GST_DEBUG_CATEGORY_INIT (gst_cv_erode_debug, "cverode", 0, "cverode");
+
+ return gst_element_register (plugin, "cverode", GST_RANK_NONE,
+ GST_TYPE_CV_ERODE);
+}
--- /dev/null
+/*
+ * 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_ERODE_H__
+#define __GST_CV_ERODE_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include "gstcvdilateerode.h"
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CV_ERODE \
+ (gst_cv_erode_get_type())
+#define GST_CV_ERODE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_ERODE,GstCvErode))
+#define GST_CV_ERODE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_ERODE,GstCvErodeClass))
+#define GST_IS_CV_ERODE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_ERODE))
+#define GST_IS_CV_ERODE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_ERODE))
+
+typedef struct _GstCvErode GstCvErode;
+typedef struct _GstCvErodeClass GstCvErodeClass;
+
+struct _GstCvErode
+{
+ GstCvDilateErode element;
+};
+
+struct _GstCvErodeClass
+{
+ GstCvDilateErodeClass parent_class;
+};
+
+GType gst_cv_erode_get_type (void);
+
+gboolean gst_cv_erode_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_CV_ERODE_H__ */
--- /dev/null
+/*
+ * 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 "gstcvlaplace.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_cv_laplace_debug);
+#define GST_CAT_DEFAULT gst_cv_laplace_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)16, bpp=(int)16, endianness=(int)4321")
+ );
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+enum
+{
+ PROP_0,
+ PROP_APERTURE_SIZE
+};
+
+#define DEFAULT_APERTURE_SIZE 3
+
+GST_BOILERPLATE (GstCvLaplace, gst_cv_laplace, GstOpencvVideoFilter,
+ GST_TYPE_OPENCV_VIDEO_FILTER);
+
+static void gst_cv_laplace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cv_laplace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstCaps *gst_cv_laplace_transform_caps (GstBaseTransform * trans,
+ GstPadDirection dir, GstCaps * caps);
+
+static GstFlowReturn gst_cv_laplace_transform (GstOpencvVideoFilter * filter,
+ GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
+
+static gboolean gst_cv_laplace_cv_set_caps (GstOpencvVideoFilter * trans,
+ gint in_width, gint in_height, gint in_depth, gint in_channels,
+ gint out_width, gint out_height, gint out_depth, gint out_channels);
+
+/* Clean up */
+static void
+gst_cv_laplace_finalize (GObject * obj)
+{
+ GstCvLaplace *filter = GST_CV_LAPLACE (obj);
+
+ if (filter->intermediary_img)
+ cvReleaseImage (&filter->intermediary_img);
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+/* GObject vmethod implementations */
+
+static void
+gst_cv_laplace_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,
+ "cvlaplace",
+ "Transform/Effect/Video",
+ "Applies cvLaplace OpenCV function to the image",
+ "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
+}
+
+/* initialize the cvlaplace's class */
+static void
+gst_cv_laplace_class_init (GstCvLaplaceClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstBaseTransformClass *gstbasetransform_class;
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstbasetransform_class = (GstBaseTransformClass *) klass;
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_laplace_finalize);
+ gobject_class->set_property = gst_cv_laplace_set_property;
+ gobject_class->get_property = gst_cv_laplace_get_property;
+
+ gstbasetransform_class->transform_caps = gst_cv_laplace_transform_caps;
+
+ gstopencvbasefilter_class->cv_trans_func = gst_cv_laplace_transform;
+ gstopencvbasefilter_class->cv_set_caps = gst_cv_laplace_cv_set_caps;
+
+ g_object_class_install_property (gobject_class, PROP_APERTURE_SIZE,
+ g_param_spec_int ("aperture-size", "aperture size",
+ "Size of the extended Laplace Kernel (1, 3, 5 or 7)", 1, 7,
+ DEFAULT_APERTURE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gst_cv_laplace_init (GstCvLaplace * filter, GstCvLaplaceClass * gclass)
+{
+ filter->aperture_size = DEFAULT_APERTURE_SIZE;
+
+ gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
+}
+
+static gboolean
+gst_cv_laplace_cv_set_caps (GstOpencvVideoFilter * trans, gint in_width,
+ gint in_height, gint in_depth, gint in_channels, gint out_width,
+ gint out_height, gint out_depth, gint out_channels)
+{
+ GstCvLaplace *filter = GST_CV_LAPLACE (trans);
+ gint intermediary_depth;
+
+ /* cvLaplace needs an signed output, so we create our intermediary step
+ * image here */
+ switch (out_depth) {
+ case IPL_DEPTH_16U:
+ intermediary_depth = IPL_DEPTH_16S;
+ break;
+ default:
+ GST_WARNING_OBJECT (filter, "Unsupported output depth %d", out_depth);
+ return FALSE;
+ }
+
+ if (filter->intermediary_img) {
+ cvReleaseImage (&filter->intermediary_img);
+ }
+
+ filter->intermediary_img = cvCreateImage (cvSize (out_width, out_height),
+ intermediary_depth, out_channels);
+
+ return TRUE;
+}
+
+static GstCaps *
+gst_cv_laplace_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
+ GstCaps * caps)
+{
+ GstCaps *output = NULL;
+ GstStructure *structure;
+ gint i;
+
+ output = gst_caps_copy (caps);
+
+ /* we accept anything from the template caps for either side */
+ switch (dir) {
+ case GST_PAD_SINK:
+ for (i = 0; i < gst_caps_get_size (output); i++) {
+ structure = gst_caps_get_structure (output, i);
+ gst_structure_set (structure,
+ "depth", G_TYPE_INT, 16,
+ "bpp", G_TYPE_INT, 16, "endianness", G_TYPE_INT, 4321, NULL);
+ }
+ break;
+ case GST_PAD_SRC:
+ for (i = 0; i < gst_caps_get_size (output); i++) {
+ structure = gst_caps_get_structure (output, i);
+ gst_structure_set (structure,
+ "depth", G_TYPE_INT, 8, "bpp", G_TYPE_INT, 8, NULL);
+ gst_structure_remove_field (structure, "endianness");
+ }
+ break;
+ default:
+ gst_caps_unref (output);
+ output = NULL;
+ g_assert_not_reached ();
+ break;
+ }
+
+ return output;
+}
+
+static void
+gst_cv_laplace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCvLaplace *filter = GST_CV_LAPLACE (object);
+
+ switch (prop_id) {
+ case PROP_APERTURE_SIZE:{
+ gint as = g_value_get_int (value);
+
+ if (as % 2 != 1) {
+ GST_WARNING_OBJECT (filter, "Invalid value %d for aperture size", as);
+ } else
+ filter->aperture_size = g_value_get_int (value);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_cv_laplace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCvLaplace *filter = GST_CV_LAPLACE (object);
+
+ switch (prop_id) {
+ case PROP_APERTURE_SIZE:
+ g_value_set_int (value, filter->aperture_size);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GstFlowReturn
+gst_cv_laplace_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img, GstBuffer * outbuf, IplImage * outimg)
+{
+ GstCvLaplace *filter = GST_CV_LAPLACE (base);
+
+ g_assert (filter->intermediary_img);
+
+ cvLaplace (img, filter->intermediary_img, filter->aperture_size);
+ cvConvertScale (filter->intermediary_img, outimg, 1, 0);
+
+ return GST_FLOW_OK;
+}
+
+gboolean
+gst_cv_laplace_plugin_init (GstPlugin * plugin)
+{
+ GST_DEBUG_CATEGORY_INIT (gst_cv_laplace_debug, "cvlaplace", 0, "cvlaplace");
+
+ return gst_element_register (plugin, "cvlaplace", GST_RANK_NONE,
+ GST_TYPE_CV_LAPLACE);
+}
--- /dev/null
+/*
+ * 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_LAPLACE_H__
+#define __GST_CV_LAPLACE_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include <gstopencvvideofilter.h>
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CV_LAPLACE \
+ (gst_cv_laplace_get_type())
+#define GST_CV_LAPLACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_LAPLACE,GstCvLaplace))
+#define GST_CV_LAPLACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_LAPLACE,GstCvLaplaceClass))
+#define GST_IS_CV_LAPLACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_LAPLACE))
+#define GST_IS_CV_LAPLACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_LAPLACE))
+
+typedef struct _GstCvLaplace GstCvLaplace;
+typedef struct _GstCvLaplaceClass GstCvLaplaceClass;
+
+struct _GstCvLaplace
+{
+ GstOpencvVideoFilter element;
+
+ gint aperture_size;
+
+ IplImage *intermediary_img;
+};
+
+struct _GstCvLaplaceClass
+{
+ GstOpencvVideoFilterClass parent_class;
+};
+
+GType gst_cv_laplace_get_type (void);
+
+gboolean gst_cv_laplace_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_CV_LAPLACE_H__ */
--- /dev/null
+/*
+ * 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 "gstcvsmooth.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_cv_smooth_debug);
+#define GST_CAT_DEFAULT gst_cv_smooth_debug
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
+ "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-rgb, depth=(int)24, bpp=(int)24;"
+ "video/x-raw-gray, depth=(int)8, bpp=(int)8")
+ );
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+enum
+{
+ PROP_0,
+ PROP_SMOOTH_TYPE,
+ PROP_PARAM1,
+ PROP_PARAM2,
+ PROP_PARAM3,
+ PROP_PARAM4
+};
+
+/* blur-no-scale only handle: gray 8bits -> gray 16bits
+ * FIXME there is no way in base transform to override pad's getcaps
+ * to be property-sensitive, instead of using the template caps as
+ * the base caps, this might lead us to negotiating rgb in this
+ * smooth type.
+ *
+ * Keep it deactivated for now.
+ */
+
+#define GST_TYPE_CV_SMOOTH_TYPE (gst_cv_smooth_type_get_type ())
+static GType
+gst_cv_smooth_type_get_type (void)
+{
+ static GType cv_smooth_type_type = 0;
+
+ static const GEnumValue smooth_types[] = {
+/* {CV_BLUR_NO_SCALE, "CV Blur No Scale", "blur-no-scale"}, */
+ {CV_BLUR, "CV Blur", "blur"},
+ {CV_GAUSSIAN, "CV Gaussian", "gaussian"},
+ {CV_MEDIAN, "CV Median", "median"},
+ {CV_BILATERAL, "CV Bilateral", "bilateral"},
+ {0, NULL, NULL},
+ };
+
+ if (!cv_smooth_type_type) {
+ cv_smooth_type_type =
+ g_enum_register_static ("GstCvSmoothTypeType", smooth_types);
+ }
+ return cv_smooth_type_type;
+}
+
+#define DEFAULT_CV_SMOOTH_TYPE CV_GAUSSIAN
+#define DEFAULT_PARAM1 3
+#define DEFAULT_PARAM2 0.0
+#define DEFAULT_PARAM3 0.0
+#define DEFAULT_PARAM4 0.0
+
+GST_BOILERPLATE (GstCvSmooth, gst_cv_smooth, GstOpencvVideoFilter,
+ GST_TYPE_OPENCV_VIDEO_FILTER);
+
+static void gst_cv_smooth_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cv_smooth_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstFlowReturn gst_cv_smooth_transform_ip (GstOpencvVideoFilter *
+ filter, GstBuffer * buf, IplImage * img);
+static GstFlowReturn gst_cv_smooth_transform (GstOpencvVideoFilter * filter,
+ GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
+
+/* Clean up */
+static void
+gst_cv_smooth_finalize (GObject * obj)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+
+/* GObject vmethod implementations */
+
+static void
+gst_cv_smooth_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,
+ "cvsmooth",
+ "Transform/Effect/Video",
+ "Applies cvSmooth OpenCV function to the image",
+ "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
+}
+
+/* initialize the cvsmooth's class */
+static void
+gst_cv_smooth_class_init (GstCvSmoothClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_smooth_finalize);
+ gobject_class->set_property = gst_cv_smooth_set_property;
+ gobject_class->get_property = gst_cv_smooth_get_property;
+
+ gstopencvbasefilter_class->cv_trans_ip_func = gst_cv_smooth_transform_ip;
+ gstopencvbasefilter_class->cv_trans_func = gst_cv_smooth_transform;
+
+ g_object_class_install_property (gobject_class, PROP_SMOOTH_TYPE,
+ g_param_spec_enum ("type",
+ "type",
+ "Smooth Type",
+ GST_TYPE_CV_SMOOTH_TYPE,
+ DEFAULT_CV_SMOOTH_TYPE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
+ );
+ g_object_class_install_property (gobject_class, PROP_PARAM1,
+ g_param_spec_int ("param1", "param1 (aperture width)",
+ "The aperture width (Must be positive and odd)."
+ "Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
+ "/documentation/image_filtering.html#cvSmooth", 1, G_MAXINT,
+ DEFAULT_PARAM1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_PARAM2,
+ g_param_spec_int ("param2", "param2 (aperture height)",
+ "The aperture height, if zero, the width is used."
+ "(Must be positive and odd or zero, unuset in median and bilateral "
+ "types). Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
+ "/documentation/image_filtering.html#cvSmooth", 0, G_MAXINT,
+ DEFAULT_PARAM2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_PARAM3,
+ g_param_spec_double ("param3", "param3 (gaussian standard deviation or "
+ "color sigma",
+ "If type is gaussian, this means the standard deviation."
+ "If type is bilateral, this means the color-sigma. If zero, "
+ "Default values are used."
+ "Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
+ "/documentation/image_filtering.html#cvSmooth",
+ 0, G_MAXDOUBLE, DEFAULT_PARAM3,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_PARAM4,
+ g_param_spec_double ("param4", "param4 (spatial sigma, bilateral only)",
+ "Only used in bilateral type, means the spatial-sigma."
+ "Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
+ "/documentation/image_filtering.html#cvSmooth",
+ 0, G_MAXDOUBLE, DEFAULT_PARAM4,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_cv_smooth_init (GstCvSmooth * filter, GstCvSmoothClass * gclass)
+{
+ filter->type = DEFAULT_CV_SMOOTH_TYPE;
+ filter->param1 = DEFAULT_PARAM1;
+ filter->param2 = DEFAULT_PARAM2;
+ filter->param3 = DEFAULT_PARAM3;
+ filter->param4 = DEFAULT_PARAM4;
+
+ gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
+}
+
+static void
+gst_cv_smooth_change_type (GstCvSmooth * filter, gint value)
+{
+ GST_DEBUG_OBJECT (filter, "Changing type from %d to %d", filter->type, value);
+ if (filter->type == value)
+ return;
+
+ filter->type = value;
+ switch (value) {
+ case CV_GAUSSIAN:
+ case CV_BLUR:
+ gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE);
+ break;
+ default:
+ gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
+ break;
+ }
+}
+
+static void
+gst_cv_smooth_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCvSmooth *filter = GST_CV_SMOOTH (object);
+
+ switch (prop_id) {
+ case PROP_SMOOTH_TYPE:
+ gst_cv_smooth_change_type (filter, g_value_get_enum (value));
+ break;
+ case PROP_PARAM1:{
+ gint prop = g_value_get_int (value);
+
+ if (prop % 2 == 1) {
+ filter->param1 = prop;
+ } else {
+ GST_WARNING_OBJECT (filter, "Ignoring value for param1, not odd"
+ "(%d)", prop);
+ }
+ }
+ break;
+ case PROP_PARAM2:{
+ gint prop = g_value_get_int (value);
+
+ if (prop % 2 == 1 || prop == 0) {
+ filter->param1 = prop;
+ } else {
+ GST_WARNING_OBJECT (filter, "Ignoring value for param2, not odd"
+ " nor zero (%d)", prop);
+ }
+ }
+ break;
+ case PROP_PARAM3:
+ filter->param3 = g_value_get_double (value);
+ break;
+ case PROP_PARAM4:
+ filter->param4 = g_value_get_double (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_cv_smooth_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCvSmooth *filter = GST_CV_SMOOTH (object);
+
+ switch (prop_id) {
+ case PROP_SMOOTH_TYPE:
+ g_value_set_enum (value, filter->type);
+ break;
+ case PROP_PARAM1:
+ g_value_set_int (value, filter->param1);
+ break;
+ case PROP_PARAM2:
+ g_value_set_int (value, filter->param2);
+ break;
+ case PROP_PARAM3:
+ g_value_set_double (value, filter->param3);
+ break;
+ case PROP_PARAM4:
+ g_value_set_double (value, filter->param4);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GstFlowReturn
+gst_cv_smooth_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img, GstBuffer * outbuf, IplImage * outimg)
+{
+ GstCvSmooth *filter = GST_CV_SMOOTH (base);
+
+ cvSmooth (img, outimg, filter->type, filter->param1, filter->param2,
+ filter->param3, filter->param4);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_cv_smooth_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img)
+{
+ GstCvSmooth *filter = GST_CV_SMOOTH (base);
+
+ cvSmooth (img, img, filter->type, filter->param1, filter->param2,
+ filter->param3, filter->param4);
+
+ return GST_FLOW_OK;
+}
+
+gboolean
+gst_cv_smooth_plugin_init (GstPlugin * plugin)
+{
+ GST_DEBUG_CATEGORY_INIT (gst_cv_smooth_debug, "cvsmooth", 0, "cvsmooth");
+
+ return gst_element_register (plugin, "cvsmooth", GST_RANK_NONE,
+ GST_TYPE_CV_SMOOTH);
+}
--- /dev/null
+/*
+ * 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_SMOOTH_H__
+#define __GST_CV_SMOOTH_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include <gstopencvvideofilter.h>
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CV_SMOOTH \
+ (gst_cv_smooth_get_type())
+#define GST_CV_SMOOTH(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_SMOOTH,GstCvSmooth))
+#define GST_CV_SMOOTH_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_SMOOTH,GstCvSmoothClass))
+#define GST_IS_CV_SMOOTH(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_SMOOTH))
+#define GST_IS_CV_SMOOTH_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_SMOOTH))
+
+typedef struct _GstCvSmooth GstCvSmooth;
+typedef struct _GstCvSmoothClass GstCvSmoothClass;
+
+struct _GstCvSmooth
+{
+ GstOpencvVideoFilter element;
+
+ gint type;
+
+ gint param1;
+ gint param2;
+ gdouble param3;
+ gdouble param4;
+};
+
+struct _GstCvSmoothClass
+{
+ GstOpencvVideoFilterClass parent_class;
+};
+
+GType gst_cv_smooth_get_type (void);
+
+gboolean gst_cv_smooth_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_CV_SMOOTH_H__ */
--- /dev/null
+/*
+ * 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 "gstcvsobel.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_cv_sobel_debug);
+#define GST_CAT_DEFAULT gst_cv_sobel_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)16, bpp=(int)16, endianness=(int)4321")
+ );
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+enum
+{
+ PROP_0,
+ PROP_X_ORDER,
+ PROP_Y_ORDER,
+ PROP_APERTURE_SIZE
+};
+
+#define DEFAULT_X_ORDER 1
+#define DEFAULT_Y_ORDER 0
+#define DEFAULT_APERTURE_SIZE 3
+
+GST_BOILERPLATE (GstCvSobel, gst_cv_sobel, GstOpencvVideoFilter,
+ GST_TYPE_OPENCV_VIDEO_FILTER);
+
+static void gst_cv_sobel_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cv_sobel_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstCaps *gst_cv_sobel_transform_caps (GstBaseTransform * trans,
+ GstPadDirection dir, GstCaps * caps);
+
+static GstFlowReturn gst_cv_sobel_transform (GstOpencvVideoFilter * filter,
+ GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
+
+/* Clean up */
+static void
+gst_cv_sobel_finalize (GObject * obj)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+/* GObject vmethod implementations */
+
+static void
+gst_cv_sobel_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,
+ "cvsobel",
+ "Transform/Effect/Video",
+ "Applies cvSobel OpenCV function to the image",
+ "Thiago Santos<thiago.sousa.santos@collabora.co.uk>");
+}
+
+/* initialize the cvsobel's class */
+static void
+gst_cv_sobel_class_init (GstCvSobelClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstBaseTransformClass *gstbasetransform_class;
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstbasetransform_class = (GstBaseTransformClass *) klass;
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_sobel_finalize);
+ gobject_class->set_property = gst_cv_sobel_set_property;
+ gobject_class->get_property = gst_cv_sobel_get_property;
+
+ gstbasetransform_class->transform_caps = gst_cv_sobel_transform_caps;
+
+ gstopencvbasefilter_class->cv_trans_func = gst_cv_sobel_transform;
+
+ g_object_class_install_property (gobject_class, PROP_X_ORDER,
+ g_param_spec_int ("x-order", "x order",
+ "Order of the derivative x", -1, G_MAXINT,
+ DEFAULT_X_ORDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_Y_ORDER,
+ g_param_spec_int ("y-order", "y order",
+ "Order of the derivative y", -1, G_MAXINT,
+ DEFAULT_Y_ORDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_APERTURE_SIZE,
+ g_param_spec_int ("aperture-size", "aperture size",
+ "Size of the extended Sobel Kernel (1, 3, 5 or 7)", 1, 7,
+ DEFAULT_APERTURE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gst_cv_sobel_init (GstCvSobel * filter, GstCvSobelClass * gclass)
+{
+ filter->x_order = DEFAULT_X_ORDER;
+ filter->y_order = DEFAULT_Y_ORDER;
+ filter->aperture_size = DEFAULT_APERTURE_SIZE;
+
+ gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), FALSE);
+}
+
+static GstCaps *
+gst_cv_sobel_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
+ GstCaps * caps)
+{
+ GstCaps *output = NULL;
+ GstStructure *structure;
+ gint i;
+
+ output = gst_caps_copy (caps);
+
+ /* we accept anything from the template caps for either side */
+ switch (dir) {
+ case GST_PAD_SINK:
+ for (i = 0; i < gst_caps_get_size (output); i++) {
+ structure = gst_caps_get_structure (output, i);
+ gst_structure_set (structure,
+ "depth", G_TYPE_INT, 16,
+ "bpp", G_TYPE_INT, 16, "endianness", G_TYPE_INT, 4321, NULL);
+ }
+ break;
+ case GST_PAD_SRC:
+ for (i = 0; i < gst_caps_get_size (output); i++) {
+ structure = gst_caps_get_structure (output, i);
+ gst_structure_set (structure,
+ "depth", G_TYPE_INT, 8, "bpp", G_TYPE_INT, 8, NULL);
+ gst_structure_remove_field (structure, "endianness");
+ }
+ break;
+ default:
+ gst_caps_unref (output);
+ output = NULL;
+ g_assert_not_reached ();
+ break;
+ }
+
+ return output;
+}
+
+static void
+gst_cv_sobel_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCvSobel *filter = GST_CV_SOBEL (object);
+
+ switch (prop_id) {
+ case PROP_X_ORDER:
+ filter->x_order = g_value_get_int (value);
+ break;
+ case PROP_Y_ORDER:
+ filter->y_order = g_value_get_int (value);
+ break;
+ case PROP_APERTURE_SIZE:{
+ gint as = g_value_get_int (value);
+
+ if (as % 2 != 1) {
+ GST_WARNING_OBJECT (filter, "Invalid value %d for aperture size", as);
+ } else
+ filter->aperture_size = g_value_get_int (value);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_cv_sobel_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCvSobel *filter = GST_CV_SOBEL (object);
+
+ switch (prop_id) {
+ case PROP_X_ORDER:
+ g_value_set_int (value, filter->x_order);
+ break;
+ case PROP_Y_ORDER:
+ g_value_set_int (value, filter->y_order);
+ break;
+ case PROP_APERTURE_SIZE:
+ g_value_set_int (value, filter->aperture_size);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GstFlowReturn
+gst_cv_sobel_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img, GstBuffer * outbuf, IplImage * outimg)
+{
+ GstCvSobel *filter = GST_CV_SOBEL (base);
+
+ cvSobel (img, outimg, filter->x_order, filter->y_order,
+ filter->aperture_size);
+
+ return GST_FLOW_OK;
+}
+
+gboolean
+gst_cv_sobel_plugin_init (GstPlugin * plugin)
+{
+ GST_DEBUG_CATEGORY_INIT (gst_cv_sobel_debug, "cvsobel", 0, "cvsobel");
+
+ return gst_element_register (plugin, "cvsobel", GST_RANK_NONE,
+ GST_TYPE_CV_SOBEL);
+}
--- /dev/null
+/*
+ * 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_SOBEL_H__
+#define __GST_CV_SOBEL_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include <gstopencvvideofilter.h>
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CV_SOBEL \
+ (gst_cv_sobel_get_type())
+#define GST_CV_SOBEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CV_SOBEL,GstCvSobel))
+#define GST_CV_SOBEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CV_SOBEL,GstCvSobelClass))
+#define GST_IS_CV_SOBEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CV_SOBEL))
+#define GST_IS_CV_SOBEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CV_SOBEL))
+
+typedef struct _GstCvSobel GstCvSobel;
+typedef struct _GstCvSobelClass GstCvSobelClass;
+
+struct _GstCvSobel
+{
+ GstOpencvVideoFilter element;
+
+ gint x_order;
+ gint y_order;
+ gint aperture_size;
+};
+
+struct _GstCvSobelClass
+{
+ GstOpencvVideoFilterClass parent_class;
+};
+
+GType gst_cv_sobel_get_type (void);
+
+gboolean gst_cv_sobel_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_CV_SOBEL_H__ */
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-edgedetect
+ *
+ * FIXME:Describe edgedetect here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! edgedetect ! ffmpegcolorspace ! xvimagesink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gstedgedetect.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_edgedetect_debug);
+#define GST_CAT_DEFAULT gst_edgedetect_debug
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_THRESHOLD1,
+ PROP_THRESHOLD2,
+ PROP_APERTURE,
+ PROP_MASK
+};
+
+/* the capabilities of the inputs and outputs.
+ *
+ * describe the real formats here.
+ */
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+GST_BOILERPLATE (Gstedgedetect, gst_edgedetect, GstElement, GST_TYPE_ELEMENT);
+
+static void gst_edgedetect_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_edgedetect_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_edgedetect_set_caps (GstPad * pad, GstCaps * caps);
+static GstFlowReturn gst_edgedetect_chain (GstPad * pad, GstBuffer * buf);
+
+/* Clean up */
+static void
+gst_edgedetect_finalize (GObject * obj)
+{
+ Gstedgedetect *filter = GST_EDGEDETECT (obj);
+
+ if (filter->cvImage != NULL) {
+ cvReleaseImage (&filter->cvImage);
+ cvReleaseImage (&filter->cvCEdge);
+ cvReleaseImage (&filter->cvGray);
+ cvReleaseImage (&filter->cvEdge);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+/* GObject vmethod implementations */
+static void
+gst_edgedetect_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "edgedetect",
+ "Filter/Effect/Video",
+ "Performs canny edge detection on videos and images.",
+ "Michael Sheldon <mike@mikeasoft.com>");
+
+ 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));
+}
+
+/* initialize the edgedetect's class */
+static void
+gst_edgedetect_class_init (GstedgedetectClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_edgedetect_finalize);
+ gobject_class->set_property = gst_edgedetect_set_property;
+ gobject_class->get_property = gst_edgedetect_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_MASK,
+ g_param_spec_boolean ("mask", "Mask",
+ "Sets whether the detected edges should be used as a mask on the original input or not",
+ TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_THRESHOLD1,
+ g_param_spec_int ("threshold1", "Threshold1",
+ "Threshold value for canny edge detection", 0, 1000, 50,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_THRESHOLD2,
+ g_param_spec_int ("threshold2", "Threshold2",
+ "Second threshold value for canny edge detection", 0, 1000, 150,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_APERTURE,
+ g_param_spec_int ("aperture", "Aperture",
+ "Aperture size for Sobel operator (Must be either 3, 5 or 7", 3, 7, 3,
+ G_PARAM_READWRITE));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_edgedetect_init (Gstedgedetect * filter, GstedgedetectClass * gclass)
+{
+ filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+ gst_pad_set_setcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_edgedetect_set_caps));
+ gst_pad_set_getcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_chain_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_edgedetect_chain));
+
+ filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_pad_set_getcaps_function (filter->srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+ filter->mask = TRUE;
+ filter->threshold1 = 50;
+ filter->threshold2 = 150;
+ filter->aperture = 3;
+}
+
+static void
+gst_edgedetect_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ Gstedgedetect *filter = GST_EDGEDETECT (object);
+
+ switch (prop_id) {
+ case PROP_MASK:
+ filter->mask = g_value_get_boolean (value);
+ break;
+ case PROP_THRESHOLD1:
+ filter->threshold1 = g_value_get_int (value);
+ break;
+ case PROP_THRESHOLD2:
+ filter->threshold2 = g_value_get_int (value);
+ break;
+ case PROP_APERTURE:
+ filter->aperture = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_edgedetect_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ Gstedgedetect *filter = GST_EDGEDETECT (object);
+
+ switch (prop_id) {
+ case PROP_MASK:
+ g_value_set_boolean (value, filter->mask);
+ break;
+ case PROP_THRESHOLD1:
+ g_value_set_int (value, filter->threshold1);
+ break;
+ case PROP_THRESHOLD2:
+ g_value_set_int (value, filter->threshold2);
+ break;
+ case PROP_APERTURE:
+ g_value_set_int (value, filter->aperture);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles the link with other elements */
+static gboolean
+gst_edgedetect_set_caps (GstPad * pad, GstCaps * caps)
+{
+ Gstedgedetect *filter;
+ GstPad *otherpad;
+ gint width, height;
+ GstStructure *structure;
+
+ filter = GST_EDGEDETECT (gst_pad_get_parent (pad));
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+
+ filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
+ filter->cvCEdge = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
+ filter->cvGray = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
+ filter->cvEdge = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
+
+ otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
+ gst_object_unref (filter);
+
+ return gst_pad_set_caps (otherpad, caps);
+}
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
+{
+ Gstedgedetect *filter;
+ GstBuffer *outbuf;
+
+ filter = GST_EDGEDETECT (GST_OBJECT_PARENT (pad));
+
+ filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
+
+ cvCvtColor (filter->cvImage, filter->cvGray, CV_RGB2GRAY);
+ cvSmooth (filter->cvGray, filter->cvEdge, CV_BLUR, 3, 3, 0, 0);
+ cvNot (filter->cvGray, filter->cvEdge);
+ cvCanny (filter->cvGray, filter->cvEdge, filter->threshold1,
+ filter->threshold2, filter->aperture);
+
+ cvZero (filter->cvCEdge);
+ if (filter->mask) {
+ cvCopy (filter->cvImage, filter->cvCEdge, filter->cvEdge);
+ } else {
+ cvCvtColor (filter->cvEdge, filter->cvCEdge, CV_GRAY2RGB);
+ }
+
+ outbuf = gst_buffer_new_and_alloc (filter->cvCEdge->imageSize);
+ gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_ALL);
+ memcpy (GST_BUFFER_DATA (outbuf), filter->cvCEdge->imageData,
+ GST_BUFFER_SIZE (outbuf));
+
+ gst_buffer_unref (buf);
+ return gst_pad_push (filter->srcpad, outbuf);
+}
+
+/* entry point to initialize the plug-in
+ * initialize the plug-in itself
+ * register the element factories and other features
+ */
+gboolean
+gst_edgedetect_plugin_init (GstPlugin * plugin)
+{
+ /* debug category for fltering log messages
+ *
+ * exchange the string 'Template edgedetect' with your description
+ */
+ GST_DEBUG_CATEGORY_INIT (gst_edgedetect_debug, "edgedetect",
+ 0, "Performs canny edge detection on videos and images");
+
+ return gst_element_register (plugin, "edgedetect", GST_RANK_NONE,
+ GST_TYPE_EDGEDETECT);
+}
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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_EDGEDETECT_H__
+#define __GST_EDGEDETECT_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+
+G_BEGIN_DECLS
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_EDGEDETECT \
+ (gst_edgedetect_get_type())
+#define GST_EDGEDETECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EDGEDETECT,Gstedgedetect))
+#define GST_EDGEDETECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EDGEDETECT,GstedgedetectClass))
+#define GST_IS_EDGEDETECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EDGEDETECT))
+#define GST_IS_EDGEDETECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EDGEDETECT))
+typedef struct _Gstedgedetect Gstedgedetect;
+typedef struct _GstedgedetectClass GstedgedetectClass;
+
+struct _Gstedgedetect
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ gboolean mask;
+
+ int threshold1, threshold2, aperture;
+
+ IplImage *cvEdge, *cvGray, *cvImage, *cvCEdge;
+};
+
+struct _GstedgedetectClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_edgedetect_get_type (void);
+
+gboolean gst_edgedetect_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+#endif /* __GST_EDGEDETECT_H__ */
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-faceblur
+ *
+ * FIXME:Describe faceblur here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! faceblur ! ffmpegcolorspace ! xvimagesink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gstfaceblur.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_faceblur_debug);
+#define GST_CAT_DEFAULT gst_faceblur_debug
+
+#define DEFAULT_PROFILE "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml"
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_PROFILE
+};
+
+/* the capabilities of the inputs and outputs.
+ */
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+GST_BOILERPLATE (Gstfaceblur, gst_faceblur, GstElement, GST_TYPE_ELEMENT);
+
+static void gst_faceblur_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_faceblur_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_faceblur_set_caps (GstPad * pad, GstCaps * caps);
+static GstFlowReturn gst_faceblur_chain (GstPad * pad, GstBuffer * buf);
+
+static void gst_faceblur_load_profile (Gstfaceblur * filter);
+
+/* Clean up */
+static void
+gst_faceblur_finalize (GObject * obj)
+{
+ Gstfaceblur *filter = GST_FACEBLUR (obj);
+
+ if (filter->cvImage) {
+ cvReleaseImage (&filter->cvImage);
+ cvReleaseImage (&filter->cvGray);
+ }
+
+ g_free (filter->profile);
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+
+/* GObject vmethod implementations */
+static void
+gst_faceblur_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "faceblur",
+ "Filter/Effect/Video",
+ "Blurs faces in images and videos",
+ "Michael Sheldon <mike@mikeasoft.com>");
+
+ 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));
+}
+
+/* initialize the faceblur's class */
+static void
+gst_faceblur_class_init (GstfaceblurClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_faceblur_finalize);
+ gobject_class->set_property = gst_faceblur_set_property;
+ gobject_class->get_property = gst_faceblur_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_PROFILE,
+ g_param_spec_string ("profile", "Profile",
+ "Location of Haar cascade file to use for face blurion",
+ DEFAULT_PROFILE, G_PARAM_READWRITE));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_faceblur_init (Gstfaceblur * filter, GstfaceblurClass * gclass)
+{
+ filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+ gst_pad_set_setcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_faceblur_set_caps));
+ gst_pad_set_getcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_chain_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_faceblur_chain));
+
+ filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_pad_set_getcaps_function (filter->srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+ filter->profile = g_strdup (DEFAULT_PROFILE);
+ gst_faceblur_load_profile (filter);
+}
+
+static void
+gst_faceblur_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ Gstfaceblur *filter = GST_FACEBLUR (object);
+
+ switch (prop_id) {
+ case PROP_PROFILE:
+ g_free (filter->profile);
+ filter->profile = g_value_dup_string (value);
+ gst_faceblur_load_profile (filter);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_faceblur_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ Gstfaceblur *filter = GST_FACEBLUR (object);
+
+ switch (prop_id) {
+ case PROP_PROFILE:
+ g_value_set_string (value, filter->profile);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles the link with other elements */
+static gboolean
+gst_faceblur_set_caps (GstPad * pad, GstCaps * caps)
+{
+ Gstfaceblur *filter;
+ GstPad *otherpad;
+ gint width, height;
+ GstStructure *structure;
+
+ filter = GST_FACEBLUR (gst_pad_get_parent (pad));
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+
+ filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
+ filter->cvGray = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 1);
+ filter->cvStorage = cvCreateMemStorage (0);
+
+ otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
+ gst_object_unref (filter);
+
+ return gst_pad_set_caps (otherpad, caps);
+}
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_faceblur_chain (GstPad * pad, GstBuffer * buf)
+{
+ Gstfaceblur *filter;
+ CvSeq *faces;
+ int i;
+
+ filter = GST_FACEBLUR (GST_OBJECT_PARENT (pad));
+
+ filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
+
+ cvCvtColor (filter->cvImage, filter->cvGray, CV_RGB2GRAY);
+ cvClearMemStorage (filter->cvStorage);
+
+ if (filter->cvCascade) {
+ faces =
+ cvHaarDetectObjects (filter->cvGray, filter->cvCascade,
+ filter->cvStorage, 1.1, 2, 0, cvSize (30, 30));
+
+ if (faces && faces->total > 0) {
+ buf = gst_buffer_make_writable (buf);
+ }
+ for (i = 0; i < (faces ? faces->total : 0); i++) {
+ CvRect *r = (CvRect *) cvGetSeqElem (faces, i);
+ cvSetImageROI (filter->cvImage, *r);
+ cvSmooth (filter->cvImage, filter->cvImage, CV_BLUR, 11, 11, 0, 0);
+ cvSmooth (filter->cvImage, filter->cvImage, CV_GAUSSIAN, 11, 11, 0, 0);
+ cvResetImageROI (filter->cvImage);
+ }
+ }
+
+ /* these filters operate in place, so we push the same buffer */
+
+ return gst_pad_push (filter->srcpad, buf);
+}
+
+
+static void
+gst_faceblur_load_profile (Gstfaceblur * filter)
+{
+ filter->cvCascade =
+ (CvHaarClassifierCascade *) cvLoad (filter->profile, 0, 0, 0);
+ if (!filter->cvCascade) {
+ GST_WARNING ("Couldn't load Haar classifier cascade: %s.", filter->profile);
+ }
+}
+
+
+/* entry point to initialize the plug-in
+ * initialize the plug-in itself
+ * register the element factories and other features
+ */
+gboolean
+gst_faceblur_plugin_init (GstPlugin * plugin)
+{
+ /* debug category for filtering log messages */
+ GST_DEBUG_CATEGORY_INIT (gst_faceblur_debug, "faceblur",
+ 0, "Blurs faces in images and videos");
+
+ return gst_element_register (plugin, "faceblur", GST_RANK_NONE,
+ GST_TYPE_FACEBLUR);
+}
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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_FACEBLUR_H__
+#define __GST_FACEBLUR_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+
+G_BEGIN_DECLS
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_FACEBLUR \
+ (gst_faceblur_get_type())
+#define GST_FACEBLUR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FACEBLUR,Gstfaceblur))
+#define GST_FACEBLUR_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FACEBLUR,GstfaceblurClass))
+#define GST_IS_FACEBLUR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FACEBLUR))
+#define GST_IS_FACEBLUR_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FACEBLUR))
+typedef struct _Gstfaceblur Gstfaceblur;
+typedef struct _GstfaceblurClass GstfaceblurClass;
+
+struct _Gstfaceblur
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ gboolean display;
+
+ gchar *profile;
+
+ IplImage *cvImage, *cvGray;
+ CvHaarClassifierCascade *cvCascade;
+ CvMemStorage *cvStorage;
+};
+
+struct _GstfaceblurClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_faceblur_get_type (void);
+
+gboolean gst_faceblur_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+#endif /* __GST_FACEBLUR_H__ */
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-facedetect
+ *
+ * FIXME:Describe facedetect here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! facedetect ! ffmpegcolorspace ! xvimagesink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gstfacedetect.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_facedetect_debug);
+#define GST_CAT_DEFAULT gst_facedetect_debug
+
+#define DEFAULT_PROFILE "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml"
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_DISPLAY,
+ PROP_PROFILE
+};
+
+/* the capabilities of the inputs and outputs.
+ */
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+GST_BOILERPLATE (Gstfacedetect, gst_facedetect, GstOpencvVideoFilter,
+ GST_TYPE_OPENCV_VIDEO_FILTER);
+
+static void gst_facedetect_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_facedetect_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_facedetect_set_caps (GstOpencvVideoFilter * transform,
+ gint in_width, gint in_height, gint in_depth, gint in_channels,
+ gint out_width, gint out_height, gint out_depth, gint out_channels);
+static GstFlowReturn gst_facedetect_transform_ip (GstOpencvVideoFilter * base,
+ GstBuffer * buf, IplImage * img);
+
+static void gst_facedetect_load_profile (Gstfacedetect * filter);
+
+/* Clean up */
+static void
+gst_facedetect_finalize (GObject * obj)
+{
+ Gstfacedetect *filter = GST_FACEDETECT (obj);
+
+ if (filter->cvGray) {
+ cvReleaseImage (&filter->cvGray);
+ }
+ if (filter->cvStorage) {
+ cvReleaseMemStorage (&filter->cvStorage);
+ }
+
+ g_free (filter->profile);
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+
+/* GObject vmethod implementations */
+static void
+gst_facedetect_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "facedetect",
+ "Filter/Effect/Video",
+ "Performs face detection on videos and images, providing detected positions via bus messages",
+ "Michael Sheldon <mike@mikeasoft.com>");
+
+ 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));
+}
+
+/* initialize the facedetect's class */
+static void
+gst_facedetect_class_init (GstfacedetectClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstOpencvVideoFilterClass *gstopencvbasefilter_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_facedetect_finalize);
+ gobject_class->set_property = gst_facedetect_set_property;
+ gobject_class->get_property = gst_facedetect_get_property;
+
+ gstopencvbasefilter_class->cv_trans_ip_func = gst_facedetect_transform_ip;
+ gstopencvbasefilter_class->cv_set_caps = gst_facedetect_set_caps;
+
+ g_object_class_install_property (gobject_class, PROP_DISPLAY,
+ g_param_spec_boolean ("display", "Display",
+ "Sets whether the detected faces should be highlighted in the output",
+ TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_PROFILE,
+ g_param_spec_string ("profile", "Profile",
+ "Location of Haar cascade file to use for face detection",
+ DEFAULT_PROFILE, G_PARAM_READWRITE));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_facedetect_init (Gstfacedetect * filter, GstfacedetectClass * gclass)
+{
+ filter->profile = g_strdup (DEFAULT_PROFILE);
+ filter->display = TRUE;
+ gst_facedetect_load_profile (filter);
+
+ gst_opencv_video_filter_set_in_place (GST_OPENCV_VIDEO_FILTER_CAST (filter),
+ TRUE);
+}
+
+static void
+gst_facedetect_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ Gstfacedetect *filter = GST_FACEDETECT (object);
+
+ switch (prop_id) {
+ case PROP_PROFILE:
+ g_free (filter->profile);
+ filter->profile = g_value_dup_string (value);
+ gst_facedetect_load_profile (filter);
+ break;
+ case PROP_DISPLAY:
+ filter->display = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_facedetect_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ Gstfacedetect *filter = GST_FACEDETECT (object);
+
+ switch (prop_id) {
+ case PROP_PROFILE:
+ g_value_set_string (value, filter->profile);
+ break;
+ case PROP_DISPLAY:
+ g_value_set_boolean (value, filter->display);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles the link with other elements */
+static gboolean
+gst_facedetect_set_caps (GstOpencvVideoFilter * transform, gint in_width,
+ gint in_height, gint in_depth, gint in_channels,
+ gint out_width, gint out_height, gint out_depth, gint out_channels)
+{
+ Gstfacedetect *filter;
+
+ filter = GST_FACEDETECT (transform);
+
+ if (filter->cvGray)
+ cvReleaseImage (&filter->cvGray);
+
+ filter->cvGray = cvCreateImage (cvSize (in_width, in_height), IPL_DEPTH_8U,
+ 1);
+
+ if (!filter->cvStorage)
+ filter->cvStorage = cvCreateMemStorage (0);
+ else
+ cvClearMemStorage (filter->cvStorage);
+
+ return TRUE;
+}
+
+static GstMessage *
+gst_facedetect_message_new (Gstfacedetect * filter, GstBuffer * buf)
+{
+ GstBaseTransform *trans = GST_BASE_TRANSFORM_CAST (filter);
+ GstStructure *s;
+ GstClockTime running_time, stream_time;
+
+ running_time = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME,
+ GST_BUFFER_TIMESTAMP (buf));
+ stream_time = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
+ GST_BUFFER_TIMESTAMP (buf));
+
+ s = gst_structure_new ("facedetect",
+ "timestamp", G_TYPE_UINT64, GST_BUFFER_TIMESTAMP (buf),
+ "stream-time", G_TYPE_UINT64, stream_time,
+ "running-time", G_TYPE_UINT64, running_time,
+ "duration", G_TYPE_UINT64, GST_BUFFER_DURATION (buf), NULL);
+
+ return gst_message_new_element (GST_OBJECT (filter), s);
+}
+
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_facedetect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
+ IplImage * img)
+{
+ Gstfacedetect *filter;
+ CvSeq *faces;
+ int i;
+
+ filter = GST_FACEDETECT (base);
+
+ cvCvtColor (img, filter->cvGray, CV_RGB2GRAY);
+ cvClearMemStorage (filter->cvStorage);
+
+ if (filter->cvCascade) {
+ GstMessage *msg = NULL;
+ GValue facelist = { 0 };
+
+ faces =
+ cvHaarDetectObjects (filter->cvGray, filter->cvCascade,
+ filter->cvStorage, 1.1, 2, 0, cvSize (30, 30));
+
+ if (faces && faces->total > 0) {
+ msg = gst_facedetect_message_new (filter, buf);
+ g_value_init (&facelist, GST_TYPE_LIST);
+ }
+
+ for (i = 0; i < (faces ? faces->total : 0); i++) {
+ CvRect *r = (CvRect *) cvGetSeqElem (faces, i);
+ GValue value = { 0 };
+
+ GstStructure *s = gst_structure_new ("face",
+ "x", G_TYPE_UINT, r->x,
+ "y", G_TYPE_UINT, r->y,
+ "width", G_TYPE_UINT, r->width,
+ "height", G_TYPE_UINT, r->height, NULL);
+
+ GstMessage *m = gst_message_new_element (GST_OBJECT (filter), s);
+
+ g_value_init (&value, GST_TYPE_STRUCTURE);
+ gst_value_set_structure (&value, s);
+ gst_value_list_append_value (&facelist, &value);
+ g_value_unset (&value);
+
+ gst_element_post_message (GST_ELEMENT (filter), m);
+
+ if (filter->display) {
+ if (gst_buffer_is_writable (buf)) {
+ CvPoint center;
+ int radius;
+ center.x = cvRound ((r->x + r->width * 0.5));
+ center.y = cvRound ((r->y + r->height * 0.5));
+ radius = cvRound ((r->width + r->height) * 0.25);
+ cvCircle (img, center, radius, CV_RGB (255, 32, 32), 3, 8, 0);
+ } else {
+ GST_DEBUG_OBJECT (filter, "Buffer is not writable, not drawing "
+ "circles for faces");
+ }
+ }
+
+ }
+
+ if (msg) {
+ gst_structure_set_value (msg->structure, "faces", &facelist);
+ g_value_unset (&facelist);
+ gst_element_post_message (GST_ELEMENT (filter), msg);
+ }
+ }
+
+ return GST_FLOW_OK;
+}
+
+
+static void
+gst_facedetect_load_profile (Gstfacedetect * filter)
+{
+ filter->cvCascade =
+ (CvHaarClassifierCascade *) cvLoad (filter->profile, 0, 0, 0);
+ if (!filter->cvCascade) {
+ GST_WARNING ("Couldn't load Haar classifier cascade: %s.", filter->profile);
+ }
+}
+
+
+/* entry point to initialize the plug-in
+ * initialize the plug-in itself
+ * register the element factories and other features
+ */
+gboolean
+gst_facedetect_plugin_init (GstPlugin * plugin)
+{
+ /* debug category for fltering log messages */
+ GST_DEBUG_CATEGORY_INIT (gst_facedetect_debug, "facedetect",
+ 0,
+ "Performs face detection on videos and images, providing detected positions via bus messages");
+
+ return gst_element_register (plugin, "facedetect", GST_RANK_NONE,
+ GST_TYPE_FACEDETECT);
+}
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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_FACEDETECT_H__
+#define __GST_FACEDETECT_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include "gstopencvvideofilter.h"
+
+G_BEGIN_DECLS
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_FACEDETECT \
+ (gst_facedetect_get_type())
+#define GST_FACEDETECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FACEDETECT,Gstfacedetect))
+#define GST_FACEDETECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FACEDETECT,GstfacedetectClass))
+#define GST_IS_FACEDETECT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FACEDETECT))
+#define GST_IS_FACEDETECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FACEDETECT))
+typedef struct _Gstfacedetect Gstfacedetect;
+typedef struct _GstfacedetectClass GstfacedetectClass;
+
+struct _Gstfacedetect
+{
+ GstOpencvVideoFilter element;
+
+ gboolean display;
+
+ gchar *profile;
+
+ IplImage *cvGray;
+ CvHaarClassifierCascade *cvCascade;
+ CvMemStorage *cvStorage;
+};
+
+struct _GstfacedetectClass
+{
+ GstOpencvVideoFilterClass parent_class;
+};
+
+GType gst_facedetect_get_type (void);
+
+gboolean gst_facedetect_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+#endif /* __GST_FACEDETECT_H__ */
#include "gstopencvutils.h"
-gboolean
+static gboolean
gst_opencv_get_ipl_depth_and_channels (GstStructure * structure,
gint * ipldepth, gint * channels, GError ** err)
{
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-pyramidsegment
+ *
+ * FIXME:Describe pyramidsegment here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v -m fakesrc ! pyramidsegment ! fakesink silent=TRUE
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gstpyramidsegment.h"
+
+#define BLOCK_SIZE 1000
+
+GST_DEBUG_CATEGORY_STATIC (gst_pyramidsegment_debug);
+#define GST_CAT_DEFAULT gst_pyramidsegment_debug
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_SILENT,
+ PROP_THRESHOLD1,
+ PROP_THRESHOLD2,
+ PROP_LEVEL
+};
+
+/* the capabilities of the inputs and outputs.
+ *
+ * describe the real formats here.
+ */
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+GST_BOILERPLATE (Gstpyramidsegment, gst_pyramidsegment, GstElement,
+ GST_TYPE_ELEMENT);
+
+static void gst_pyramidsegment_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_pyramidsegment_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_pyramidsegment_set_caps (GstPad * pad, GstCaps * caps);
+static GstFlowReturn gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf);
+
+/* Clean up */
+static void
+gst_pyramidsegment_finalize (GObject * obj)
+{
+ Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (obj);
+
+ if (filter->cvImage != NULL) {
+ cvReleaseImage (&filter->cvImage);
+ cvReleaseImage (&filter->cvSegmentedImage);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+/* GObject vmethod implementations */
+static void
+gst_pyramidsegment_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "pyramidsegment",
+ "Filter/Effect/Video",
+ "Applies pyramid segmentation to a video or image.",
+ "Michael Sheldon <mike@mikeasoft.com>");
+
+ 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));
+}
+
+/* initialize the pyramidsegment's class */
+static void
+gst_pyramidsegment_class_init (GstpyramidsegmentClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_pyramidsegment_finalize);
+ gobject_class->set_property = gst_pyramidsegment_set_property;
+ gobject_class->get_property = gst_pyramidsegment_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_SILENT,
+ g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
+ FALSE, G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_THRESHOLD1,
+ g_param_spec_double ("threshold1", "Threshold1",
+ "Error threshold for establishing links", 0, 1000, 50,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_THRESHOLD2,
+ g_param_spec_double ("threshold2", "Threshold2",
+ "Error threshold for segment clustering", 0, 1000, 60,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_LEVEL,
+ g_param_spec_int ("level", "Level",
+ "Maximum level of the pyramid segmentation", 0, 4, 4,
+ G_PARAM_READWRITE));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_pyramidsegment_init (Gstpyramidsegment * filter,
+ GstpyramidsegmentClass * gclass)
+{
+ filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+ gst_pad_set_setcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pyramidsegment_set_caps));
+ gst_pad_set_getcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_chain_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pyramidsegment_chain));
+
+ filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_pad_set_getcaps_function (filter->srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+ filter->storage = cvCreateMemStorage (BLOCK_SIZE);
+ filter->comp =
+ cvCreateSeq (0, sizeof (CvSeq), sizeof (CvPoint), filter->storage);
+ filter->silent = FALSE;
+ filter->threshold1 = 50.0;
+ filter->threshold2 = 60.0;
+ filter->level = 4;
+}
+
+static void
+gst_pyramidsegment_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (object);
+
+ switch (prop_id) {
+ case PROP_SILENT:
+ filter->silent = g_value_get_boolean (value);
+ break;
+ case PROP_THRESHOLD1:
+ filter->threshold1 = g_value_get_double (value);
+ break;
+ case PROP_THRESHOLD2:
+ filter->threshold2 = g_value_get_double (value);
+ break;
+ case PROP_LEVEL:
+ filter->level = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_pyramidsegment_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (object);
+
+ switch (prop_id) {
+ case PROP_SILENT:
+ g_value_set_boolean (value, filter->silent);
+ break;
+ case PROP_THRESHOLD1:
+ g_value_set_double (value, filter->threshold1);
+ break;
+ case PROP_THRESHOLD2:
+ g_value_set_double (value, filter->threshold2);
+ break;
+ case PROP_LEVEL:
+ g_value_set_int (value, filter->level);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles the link with other elements */
+static gboolean
+gst_pyramidsegment_set_caps (GstPad * pad, GstCaps * caps)
+{
+ Gstpyramidsegment *filter;
+ GstPad *otherpad;
+ GstStructure *structure;
+ gint width, height;
+
+ filter = GST_PYRAMIDSEGMENT (gst_pad_get_parent (pad));
+
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+
+ filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
+
+ otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
+ gst_object_unref (filter);
+
+ return gst_pad_set_caps (otherpad, caps);
+}
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf)
+{
+ Gstpyramidsegment *filter;
+ GstBuffer *outbuf;
+
+ filter = GST_PYRAMIDSEGMENT (GST_OBJECT_PARENT (pad));
+
+ filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
+ filter->cvSegmentedImage = cvCloneImage (filter->cvImage);
+
+ cvPyrSegmentation (filter->cvImage, filter->cvSegmentedImage, filter->storage,
+ &(filter->comp), filter->level, filter->threshold1, filter->threshold2);
+
+ /* TODO look if there is a way in opencv to reuse the image data and
+ * delete only the struct headers. Would avoid a memcpy here */
+
+ outbuf = gst_buffer_new_and_alloc (filter->cvSegmentedImage->imageSize);
+ gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_ALL);
+ memcpy (GST_BUFFER_DATA (outbuf), filter->cvSegmentedImage->imageData,
+ GST_BUFFER_SIZE (outbuf));
+
+ gst_buffer_unref (buf);
+ cvReleaseImage (&filter->cvSegmentedImage);
+ g_assert (filter->cvSegmentedImage == NULL);
+
+ return gst_pad_push (filter->srcpad, outbuf);
+}
+
+
+/* entry point to initialize the plug-in
+ * initialize the plug-in itself
+ * register the element factories and other features
+ */
+gboolean
+gst_pyramidsegment_plugin_init (GstPlugin * plugin)
+{
+ /* debug category for fltering log messages */
+ GST_DEBUG_CATEGORY_INIT (gst_pyramidsegment_debug, "pyramidsegment",
+ 0, "Applies pyramid segmentation to a video or image");
+
+ return gst_element_register (plugin, "pyramidsegment", GST_RANK_NONE,
+ GST_TYPE_PYRAMIDSEGMENT);
+}
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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_PYRAMIDSEGMENT_H__
+#define __GST_PYRAMIDSEGMENT_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+
+G_BEGIN_DECLS
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_PYRAMIDSEGMENT \
+ (gst_pyramidsegment_get_type())
+#define GST_PYRAMIDSEGMENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PYRAMIDSEGMENT,Gstpyramidsegment))
+#define GST_PYRAMIDSEGMENT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PYRAMIDSEGMENT,GstpyramidsegmentClass))
+#define GST_IS_PYRAMIDSEGMENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PYRAMIDSEGMENT))
+#define GST_IS_PYRAMIDSEGMENT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PYRAMIDSEGMENT))
+typedef struct _Gstpyramidsegment Gstpyramidsegment;
+typedef struct _GstpyramidsegmentClass GstpyramidsegmentClass;
+
+struct _Gstpyramidsegment
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ gboolean silent;
+
+ IplImage *cvImage, *cvSegmentedImage;
+
+ CvMemStorage *storage;
+
+ CvSeq *comp;
+
+ double threshold1, threshold2;
+
+ int level;
+};
+
+struct _GstpyramidsegmentClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_pyramidsegment_get_type (void);
+
+gboolean gst_pyramidsegment_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+#endif /* __GST_PYRAMIDSEGMENT_H__ */
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ * Copyright (C) 2009 Noam Lewis <jones.noamle@gmail.com>
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-templatematch
+ *
+ * FIXME:Describe templatematch here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! templatematch template=/path/to/file.jpg ! ffmpegcolorspace ! xvimagesink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gsttemplatematch.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_templatematch_debug);
+#define GST_CAT_DEFAULT gst_templatematch_debug
+
+#define DEFAULT_METHOD (3)
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_METHOD,
+ PROP_TEMPLATE,
+ PROP_DISPLAY,
+};
+
+/* the capabilities of the inputs and outputs.
+ */
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+GST_BOILERPLATE (GstTemplateMatch, gst_templatematch, GstElement,
+ GST_TYPE_ELEMENT);
+
+static void gst_templatematch_finalize (GObject * object);
+static void gst_templatematch_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_templatematch_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_templatematch_set_caps (GstPad * pad, GstCaps * caps);
+static GstFlowReturn gst_templatematch_chain (GstPad * pad, GstBuffer * buf);
+
+static void gst_templatematch_load_template (GstTemplateMatch * filter);
+static void gst_templatematch_match (IplImage * input, IplImage * template,
+ IplImage * dist_image, double *best_res, CvPoint * best_pos, int method);
+
+/* GObject vmethod implementations */
+
+static void
+gst_templatematch_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "templatematch",
+ "Filter/Effect/Video",
+ "Performs template matching on videos and images, providing detected positions via bus messages",
+ "Noam Lewis <jones.noamle@gmail.com>");
+
+ 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));
+}
+
+/* initialize the templatematch's class */
+static void
+gst_templatematch_class_init (GstTemplateMatchClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+
+ gobject_class->finalize = gst_templatematch_finalize;
+ gobject_class->set_property = gst_templatematch_set_property;
+ gobject_class->get_property = gst_templatematch_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_METHOD,
+ g_param_spec_int ("method", "Method",
+ "Specifies the way the template must be compared with image regions. 0=SQDIFF, 1=SQDIFF_NORMED, 2=CCOR, 3=CCOR_NORMED, 4=CCOEFF, 5=CCOEFF_NORMED.",
+ 0, 5, DEFAULT_METHOD, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_TEMPLATE,
+ g_param_spec_string ("template", "Template", "Filename of template image",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_DISPLAY,
+ g_param_spec_boolean ("display", "Display",
+ "Sets whether the detected template should be highlighted in the output",
+ TRUE, G_PARAM_READWRITE));
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_templatematch_init (GstTemplateMatch * filter,
+ GstTemplateMatchClass * gclass)
+{
+ filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+ gst_pad_set_setcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_templatematch_set_caps));
+ gst_pad_set_getcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_chain_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_templatematch_chain));
+
+ filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_pad_set_getcaps_function (filter->srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+ filter->template = NULL;
+ filter->display = TRUE;
+ filter->cvTemplateImage = NULL;
+ filter->cvDistImage = NULL;
+ filter->cvImage = NULL;
+ filter->method = DEFAULT_METHOD;
+ gst_templatematch_load_template (filter);
+}
+
+static void
+gst_templatematch_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
+
+ switch (prop_id) {
+ case PROP_METHOD:
+ switch (g_value_get_int (value)) {
+ case 0:
+ filter->method = CV_TM_SQDIFF;
+ break;
+ case 1:
+ filter->method = CV_TM_SQDIFF_NORMED;
+ break;
+ case 2:
+ filter->method = CV_TM_CCORR;
+ break;
+ case 3:
+ filter->method = CV_TM_CCORR_NORMED;
+ break;
+ case 4:
+ filter->method = CV_TM_CCOEFF;
+ break;
+ case 5:
+ filter->method = CV_TM_CCOEFF_NORMED;
+ break;
+ }
+ break;
+ case PROP_TEMPLATE:
+ filter->template = (char *) g_value_get_string (value);
+ gst_templatematch_load_template (filter);
+ break;
+ case PROP_DISPLAY:
+ filter->display = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_templatematch_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
+
+ switch (prop_id) {
+ case PROP_METHOD:
+ g_value_set_int (value, filter->method);
+ break;
+ case PROP_TEMPLATE:
+ g_value_set_string (value, filter->template);
+ break;
+ case PROP_DISPLAY:
+ g_value_set_boolean (value, filter->display);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles the link with other elements */
+static gboolean
+gst_templatematch_set_caps (GstPad * pad, GstCaps * caps)
+{
+ GstTemplateMatch *filter;
+ GstPad *otherpad;
+ gint width, height;
+ GstStructure *structure;
+
+ filter = GST_TEMPLATEMATCH (gst_pad_get_parent (pad));
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+
+ filter->cvImage =
+ cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, 3);
+
+ otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
+ gst_object_unref (filter);
+
+ return gst_pad_set_caps (otherpad, caps);
+}
+
+static void
+gst_templatematch_finalize (GObject * object)
+{
+ GstTemplateMatch *filter;
+ filter = GST_TEMPLATEMATCH (object);
+
+ if (filter->cvImage) {
+ cvReleaseImageHeader (&filter->cvImage);
+ }
+ if (filter->cvDistImage) {
+ cvReleaseImage (&filter->cvDistImage);
+ }
+ if (filter->cvTemplateImage) {
+ cvReleaseImage (&filter->cvTemplateImage);
+ }
+}
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_templatematch_chain (GstPad * pad, GstBuffer * buf)
+{
+ GstTemplateMatch *filter;
+ CvPoint best_pos;
+ double best_res;
+
+ filter = GST_TEMPLATEMATCH (GST_OBJECT_PARENT (pad));
+
+ /* FIXME Why template == NULL returns OK?
+ * shouldn't it be a passthrough instead? */
+ if ((!filter) || (!buf) || filter->template == NULL) {
+ return GST_FLOW_OK;
+ }
+ filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
+
+ if (!filter->cvDistImage) {
+ filter->cvDistImage =
+ cvCreateImage (cvSize (filter->cvImage->width -
+ filter->cvTemplateImage->width + 1,
+ filter->cvImage->height - filter->cvTemplateImage->height + 1),
+ IPL_DEPTH_32F, 1);
+ if (!filter->cvDistImage) {
+ GST_WARNING ("Couldn't create dist image.");
+ }
+ }
+ if (filter->cvTemplateImage) {
+ GstStructure *s;
+ GstMessage *m;
+
+ gst_templatematch_match (filter->cvImage, filter->cvTemplateImage,
+ filter->cvDistImage, &best_res, &best_pos, filter->method);
+
+ s = gst_structure_new ("template_match",
+ "x", G_TYPE_UINT, best_pos.x,
+ "y", G_TYPE_UINT, best_pos.y,
+ "width", G_TYPE_UINT, filter->cvTemplateImage->width,
+ "height", G_TYPE_UINT, filter->cvTemplateImage->height,
+ "result", G_TYPE_DOUBLE, best_res, NULL);
+
+ m = gst_message_new_element (GST_OBJECT (filter), s);
+ gst_element_post_message (GST_ELEMENT (filter), m);
+
+ if (filter->display) {
+ CvPoint corner = best_pos;
+
+ buf = gst_buffer_make_writable (buf);
+
+ corner.x += filter->cvTemplateImage->width;
+ corner.y += filter->cvTemplateImage->height;
+ cvRectangle (filter->cvImage, best_pos, corner, CV_RGB (255, 32, 32), 3,
+ 8, 0);
+ }
+
+ }
+
+ return gst_pad_push (filter->srcpad, buf);
+}
+
+
+
+static void
+gst_templatematch_match (IplImage * input, IplImage * template,
+ IplImage * dist_image, double *best_res, CvPoint * best_pos, int method)
+{
+ double dist_min = 0, dist_max = 0;
+ CvPoint min_pos, max_pos;
+ cvMatchTemplate (input, template, dist_image, method);
+ cvMinMaxLoc (dist_image, &dist_min, &dist_max, &min_pos, &max_pos, NULL);
+ if ((CV_TM_SQDIFF_NORMED == method) || (CV_TM_SQDIFF == method)) {
+ *best_res = dist_min;
+ *best_pos = min_pos;
+ if (CV_TM_SQDIFF_NORMED == method) {
+ *best_res = 1 - *best_res;
+ }
+ } else {
+ *best_res = dist_max;
+ *best_pos = max_pos;
+ }
+}
+
+
+static void
+gst_templatematch_load_template (GstTemplateMatch * filter)
+{
+ if (filter->template) {
+ filter->cvTemplateImage =
+ cvLoadImage (filter->template, CV_LOAD_IMAGE_COLOR);
+ if (!filter->cvTemplateImage) {
+ GST_WARNING ("Couldn't load template image: %s.", filter->template);
+ }
+ }
+}
+
+
+/* entry point to initialize the plug-in
+ * initialize the plug-in itself
+ * register the element factories and other features
+ */
+gboolean
+gst_templatematch_plugin_init (GstPlugin * templatematch)
+{
+ /* debug category for fltering log messages */
+ GST_DEBUG_CATEGORY_INIT (gst_templatematch_debug, "templatematch",
+ 0,
+ "Performs template matching on videos and images, providing detected positions via bus messages");
+
+ return gst_element_register (templatematch, "templatematch", GST_RANK_NONE,
+ GST_TYPE_TEMPLATEMATCH);
+}
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
+ *
+ * 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_TEMPLATEMATCH_H__
+#define __GST_TEMPLATEMATCH_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include <highgui.h>
+
+G_BEGIN_DECLS
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_TEMPLATEMATCH \
+ (gst_templatematch_get_type())
+#define GST_TEMPLATEMATCH(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TEMPLATEMATCH,GstTemplateMatch))
+#define GST_TEMPLATEMATCH_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TEMPLATEMATCH,GstTemplateMatchClass))
+#define GST_IS_TEMPLATEMATCH(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEMPLATEMATCH))
+#define GST_IS_TEMPLATEMATCH_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEMPLATEMATCH))
+typedef struct _GstTemplateMatch GstTemplateMatch;
+typedef struct _GstTemplateMatchClass GstTemplateMatchClass;
+
+struct _GstTemplateMatch
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ gint method;
+ gboolean display;
+
+ gchar *template;
+
+ IplImage *cvImage, *cvGray, *cvTemplateImage, *cvDistImage;
+};
+
+struct _GstTemplateMatchClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_templatematch_get_type (void);
+
+gboolean gst_templatematch_plugin_init (GstPlugin * templatematch);
+
+G_END_DECLS
+#endif /* __GST_TEMPLATEMATCH_H__ */
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2010 Sreerenj Balachandran <bsreerenj@gmail.com>
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:element-textwrite
+ *
+ * FIXME:Describe textwrite here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v -m fakesrc ! textwrite ! fakesink silent=TRUE
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gsttextwrite.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_textwrite_debug);
+#define GST_CAT_DEFAULT gst_textwrite_debug
+#define DEFAULT_PROP_TEXT ""
+#define DEFAULT_PROP_WIDTH 1
+#define DEFAULT_PROP_HEIGHT 1
+#define DEFAULT_PROP_XPOS 50
+#define DEFAULT_PROP_YPOS 50
+#define DEFAULT_PROP_THICKNESS 2
+#define DEFAULT_PROP_COLOR 0
+
+
+/* Filter signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+#define DEFAULT_WIDTH 1.0
+#define DEFAULT_HEIGHT 1.0
+enum
+{
+ PROP_0,
+ PROP_XPOS,
+ PROP_YPOS,
+ PROP_THICKNESS,
+ PROP_COLOR_R,
+ PROP_COLOR_G,
+ PROP_COLOR_B,
+ PROP_TEXT,
+ PROP_HEIGHT,
+ PROP_WIDTH
+};
+
+/* the capabilities of the inputs and outputs.
+ *
+ * describe the real formats here.
+ */
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-rgb")
+ );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("ANY")
+ );
+
+GST_BOILERPLATE (Gsttextwrite, gst_textwrite, GstElement, GST_TYPE_ELEMENT);
+
+static void gst_textwrite_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_textwrite_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_textwrite_set_caps (GstPad * pad, GstCaps * caps);
+static GstFlowReturn gst_textwrite_chain (GstPad * pad, GstBuffer * buf);
+
+
+
+/* Clean up */
+static void
+gst_textwrite_finalize (GObject * obj)
+{
+ Gsttextwrite *filter = GST_textwrite (obj);
+
+ if (filter->cvImage) {
+ cvReleaseImage (&filter->cvImage);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+
+
+/* GObject vmethod implementations */
+
+static void
+gst_textwrite_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "textwrite",
+ "Filter/Effect/Video",
+ "Performs text writing to the video", "sreerenj<bsreerenj@gmail.com>");
+
+ 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));
+}
+
+/* initialize the textwrite's class */
+static void
+gst_textwrite_class_init (GsttextwriteClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_textwrite_finalize);
+
+ gobject_class->set_property = gst_textwrite_set_property;
+ gobject_class->get_property = gst_textwrite_get_property;
+
+
+ g_object_class_install_property (gobject_class, PROP_TEXT,
+ g_param_spec_string ("text", "text",
+ "Text to be display.", DEFAULT_PROP_TEXT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_XPOS,
+ g_param_spec_int ("xpos", "horizontal position",
+ "Sets the Horizontal position", 0, G_MAXINT,
+ DEFAULT_PROP_XPOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_YPOS,
+ g_param_spec_int ("ypos", "vertical position",
+ "Sets the Vertical position", 0, G_MAXINT,
+ DEFAULT_PROP_YPOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_THICKNESS,
+ g_param_spec_int ("thickness", "font thickness",
+ "Sets the Thickness of Font", 0, G_MAXINT,
+ DEFAULT_PROP_THICKNESS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_COLOR_R,
+ g_param_spec_int ("colorR", "color -Red ",
+ "Sets the color -R", 0, 255,
+ DEFAULT_PROP_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_COLOR_G,
+ g_param_spec_int ("colorG", "color -Green",
+ "Sets the color -G", 0, 255,
+ DEFAULT_PROP_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_COLOR_B,
+ g_param_spec_int ("colorB", "color -Blue",
+ "Sets the color -B", 0, 255,
+ DEFAULT_PROP_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+
+
+ g_object_class_install_property (gobject_class, PROP_HEIGHT,
+ g_param_spec_double ("height", "Height",
+ "Sets the height of fonts", 1.0, 5.0,
+ DEFAULT_HEIGHT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_WIDTH,
+ g_param_spec_double ("width", "Width",
+ "Sets the width of fonts", 1.0, 5.0,
+ DEFAULT_WIDTH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set pad calback functions
+ * initialize instance structure
+ */
+static void
+gst_textwrite_init (Gsttextwrite * filter, GsttextwriteClass * gclass)
+{
+ filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+ gst_pad_set_setcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_textwrite_set_caps));
+ gst_pad_set_getcaps_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_chain_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_textwrite_chain));
+
+ filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_pad_set_getcaps_function (filter->srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+ filter->textbuf = g_strdup (DEFAULT_PROP_TEXT);
+ filter->width = DEFAULT_PROP_WIDTH;
+ filter->height = DEFAULT_PROP_HEIGHT;
+ filter->xpos = DEFAULT_PROP_XPOS;
+ filter->ypos = DEFAULT_PROP_YPOS;
+ filter->thickness = DEFAULT_PROP_THICKNESS;
+ filter->colorR = DEFAULT_PROP_COLOR;
+ filter->colorG = DEFAULT_PROP_COLOR;
+ filter->colorB = DEFAULT_PROP_COLOR;
+
+}
+
+static void
+gst_textwrite_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ Gsttextwrite *filter = GST_textwrite (object);
+
+ switch (prop_id) {
+ case PROP_TEXT:
+ g_free (filter->textbuf);
+ filter->textbuf = g_value_dup_string (value);
+ break;
+ case PROP_XPOS:
+ filter->xpos = g_value_get_int (value);
+ break;
+ case PROP_YPOS:
+ filter->ypos = g_value_get_int (value);
+ break;
+ case PROP_THICKNESS:
+ filter->thickness = g_value_get_int (value);
+ break;
+
+ case PROP_COLOR_R:
+ filter->colorR = g_value_get_int (value);
+ break;
+ case PROP_COLOR_G:
+ filter->colorG = g_value_get_int (value);
+ break;
+ case PROP_COLOR_B:
+ filter->colorB = g_value_get_int (value);
+ break;
+
+ case PROP_HEIGHT:
+ filter->height = g_value_get_double (value);
+ break;
+ case PROP_WIDTH:
+ filter->width = g_value_get_double (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_textwrite_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ Gsttextwrite *filter = GST_textwrite (object);
+
+ switch (prop_id) {
+ case PROP_TEXT:
+ g_value_set_string (value, filter->textbuf);
+ break;
+ case PROP_XPOS:
+ g_value_set_int (value, filter->xpos);
+ break;
+ case PROP_YPOS:
+ g_value_set_int (value, filter->ypos);
+ break;
+ case PROP_THICKNESS:
+ g_value_set_int (value, filter->thickness);
+ break;
+ case PROP_COLOR_R:
+ g_value_set_int (value, filter->colorR);
+ break;
+ case PROP_COLOR_G:
+ g_value_set_int (value, filter->colorG);
+ break;
+ case PROP_COLOR_B:
+ g_value_set_int (value, filter->colorB);
+ break;
+ case PROP_HEIGHT:
+ g_value_set_double (value, filter->height);
+ break;
+ case PROP_WIDTH:
+ g_value_set_double (value, filter->width);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* GstElement vmethod implementations */
+
+/* this function handles the link with other elements */
+static gboolean
+gst_textwrite_set_caps (GstPad * pad, GstCaps * caps)
+{
+ Gsttextwrite *filter;
+ GstPad *otherpad;
+
+ gint width, height;
+ GstStructure *structure;
+
+ filter = GST_textwrite (gst_pad_get_parent (pad));
+
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+
+ filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
+ filter->cvStorage = cvCreateMemStorage (0);
+
+ otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
+ gst_object_unref (filter);
+
+ return gst_pad_set_caps (otherpad, caps);
+}
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_textwrite_chain (GstPad * pad, GstBuffer * buf)
+{
+ Gsttextwrite *filter;
+
+ filter = GST_textwrite (GST_OBJECT_PARENT (pad));
+
+ filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
+
+ cvInitFont (&(filter->font), CV_FONT_VECTOR0, filter->width, filter->height,
+ 0, filter->thickness, 0);
+
+ buf = gst_buffer_make_writable (buf);
+ cvPutText (filter->cvImage, filter->textbuf, cvPoint (filter->xpos,
+ filter->ypos), &(filter->font), cvScalar (filter->colorR,
+ filter->colorG, filter->colorB, 0));
+
+ return gst_pad_push (filter->srcpad, buf);
+}
+
+
+/* entry point to initialize the plug-in
+ * initialize the plug-in itself
+ * register the element factories and other features
+ */
+gboolean
+gst_textwrite_plugin_init (GstPlugin * plugin)
+{
+ /* debug category for fltering log messages
+ *
+ * exchange the string 'Template textwrite' with your description
+ */
+ GST_DEBUG_CATEGORY_INIT (gst_textwrite_debug, "textwrite",
+ 0, "Template textwrite");
+
+ return gst_element_register (plugin, "textwrite", GST_RANK_NONE,
+ GST_TYPE_textwrite);
+}
--- /dev/null
+/*
+ * GStreamer
+ * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
+ * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2010 root <<user@hostname.org>>m
+ *
+ * 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_textwrite_H__
+#define __GST_textwrite_H__
+
+#include <gst/gst.h>
+#include <cv.h>
+#include <cvaux.h>
+#include <highgui.h>
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_textwrite \
+ (gst_textwrite_get_type())
+#define GST_textwrite(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_textwrite,Gsttextwrite))
+#define GST_textwrite_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_textwrite,GsttextwriteClass))
+#define GST_IS_textwrite(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_textwrite))
+#define GST_IS_textwrite_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_textwrite))
+
+typedef struct _Gsttextwrite Gsttextwrite;
+typedef struct _GsttextwriteClass GsttextwriteClass;
+
+struct _Gsttextwrite
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+
+ IplImage *cvImage;
+ CvMemStorage *cvStorage;
+ CvFont font;
+
+ gint xpos;
+ gint ypos;
+ gint thickness;
+ gint colorR,colorG,colorB;
+ gdouble height;
+ gdouble width;
+ gchar *textbuf;
+
+};
+
+struct _GsttextwriteClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_textwrite_get_type (void);
+gboolean gst_textwrite_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_textwrite_H__ */
+++ /dev/null
-noinst_LTLIBRARIES = libgstpyramidsegment.la
-
-# sources used to compile this plug-in
-libgstpyramidsegment_la_SOURCES = gstpyramidsegment.c
-
-# flags used to compile this pyramidsegment
-# add other _CFLAGS and _LIBS as needed
-libgstpyramidsegment_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS)
-libgstpyramidsegment_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
-libgstpyramidsegment_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gstpyramidsegment.h
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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.
- */
-
-/**
- * SECTION:element-pyramidsegment
- *
- * FIXME:Describe pyramidsegment here.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch -v -m fakesrc ! pyramidsegment ! fakesink silent=TRUE
- * ]|
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gstpyramidsegment.h"
-
-#define BLOCK_SIZE 1000
-
-GST_DEBUG_CATEGORY_STATIC (gst_pyramidsegment_debug);
-#define GST_CAT_DEFAULT gst_pyramidsegment_debug
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_SILENT,
- PROP_THRESHOLD1,
- PROP_THRESHOLD2,
- PROP_LEVEL
-};
-
-/* the capabilities of the inputs and outputs.
- *
- * describe the real formats here.
- */
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-GST_BOILERPLATE (Gstpyramidsegment, gst_pyramidsegment, GstElement,
- GST_TYPE_ELEMENT);
-
-static void gst_pyramidsegment_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_pyramidsegment_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_pyramidsegment_set_caps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf);
-
-/* Clean up */
-static void
-gst_pyramidsegment_finalize (GObject * obj)
-{
- Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (obj);
-
- if (filter->cvImage != NULL) {
- cvReleaseImage (&filter->cvImage);
- cvReleaseImage (&filter->cvSegmentedImage);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-/* GObject vmethod implementations */
-static void
-gst_pyramidsegment_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "pyramidsegment",
- "Filter/Effect/Video",
- "Applies pyramid segmentation to a video or image.",
- "Michael Sheldon <mike@mikeasoft.com>");
-
- 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));
-}
-
-/* initialize the pyramidsegment's class */
-static void
-gst_pyramidsegment_class_init (GstpyramidsegmentClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_pyramidsegment_finalize);
- gobject_class->set_property = gst_pyramidsegment_set_property;
- gobject_class->get_property = gst_pyramidsegment_get_property;
-
- g_object_class_install_property (gobject_class, PROP_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
- FALSE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_THRESHOLD1,
- g_param_spec_double ("threshold1", "Threshold1",
- "Error threshold for establishing links", 0, 1000, 50,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_THRESHOLD2,
- g_param_spec_double ("threshold2", "Threshold2",
- "Error threshold for segment clustering", 0, 1000, 60,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_LEVEL,
- g_param_spec_int ("level", "Level",
- "Maximum level of the pyramid segmentation", 0, 4, 4,
- G_PARAM_READWRITE));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_pyramidsegment_init (Gstpyramidsegment * filter,
- GstpyramidsegmentClass * gclass)
-{
- filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pyramidsegment_set_caps));
- gst_pad_set_getcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
- gst_pad_set_chain_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pyramidsegment_chain));
-
- filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_pad_set_getcaps_function (filter->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
-
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- filter->storage = cvCreateMemStorage (BLOCK_SIZE);
- filter->comp =
- cvCreateSeq (0, sizeof (CvSeq), sizeof (CvPoint), filter->storage);
- filter->silent = FALSE;
- filter->threshold1 = 50.0;
- filter->threshold2 = 60.0;
- filter->level = 4;
-}
-
-static void
-gst_pyramidsegment_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (object);
-
- switch (prop_id) {
- case PROP_SILENT:
- filter->silent = g_value_get_boolean (value);
- break;
- case PROP_THRESHOLD1:
- filter->threshold1 = g_value_get_double (value);
- break;
- case PROP_THRESHOLD2:
- filter->threshold2 = g_value_get_double (value);
- break;
- case PROP_LEVEL:
- filter->level = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_pyramidsegment_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (object);
-
- switch (prop_id) {
- case PROP_SILENT:
- g_value_set_boolean (value, filter->silent);
- break;
- case PROP_THRESHOLD1:
- g_value_set_double (value, filter->threshold1);
- break;
- case PROP_THRESHOLD2:
- g_value_set_double (value, filter->threshold2);
- break;
- case PROP_LEVEL:
- g_value_set_int (value, filter->level);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* GstElement vmethod implementations */
-
-/* this function handles the link with other elements */
-static gboolean
-gst_pyramidsegment_set_caps (GstPad * pad, GstCaps * caps)
-{
- Gstpyramidsegment *filter;
- GstPad *otherpad;
- GstStructure *structure;
- gint width, height;
-
- filter = GST_PYRAMIDSEGMENT (gst_pad_get_parent (pad));
-
- structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
- filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
-
- otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
- gst_object_unref (filter);
-
- return gst_pad_set_caps (otherpad, caps);
-}
-
-/* chain function
- * this function does the actual processing
- */
-static GstFlowReturn
-gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf)
-{
- Gstpyramidsegment *filter;
- GstBuffer *outbuf;
-
- filter = GST_PYRAMIDSEGMENT (GST_OBJECT_PARENT (pad));
-
- filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
- filter->cvSegmentedImage = cvCloneImage (filter->cvImage);
-
- cvPyrSegmentation (filter->cvImage, filter->cvSegmentedImage, filter->storage,
- &(filter->comp), filter->level, filter->threshold1, filter->threshold2);
-
- /* TODO look if there is a way in opencv to reuse the image data and
- * delete only the struct headers. Would avoid a memcpy here */
-
- outbuf = gst_buffer_new_and_alloc (filter->cvSegmentedImage->imageSize);
- gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_ALL);
- memcpy (GST_BUFFER_DATA (outbuf), filter->cvSegmentedImage->imageData,
- GST_BUFFER_SIZE (outbuf));
-
- gst_buffer_unref (buf);
- cvReleaseImage (&filter->cvSegmentedImage);
- g_assert (filter->cvSegmentedImage == NULL);
-
- return gst_pad_push (filter->srcpad, outbuf);
-}
-
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_pyramidsegment_plugin_init (GstPlugin * plugin)
-{
- /* debug category for fltering log messages */
- GST_DEBUG_CATEGORY_INIT (gst_pyramidsegment_debug, "pyramidsegment",
- 0, "Applies pyramid segmentation to a video or image");
-
- return gst_element_register (plugin, "pyramidsegment", GST_RANK_NONE,
- GST_TYPE_PYRAMIDSEGMENT);
-}
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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_PYRAMIDSEGMENT_H__
-#define __GST_PYRAMIDSEGMENT_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-
-G_BEGIN_DECLS
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_PYRAMIDSEGMENT \
- (gst_pyramidsegment_get_type())
-#define GST_PYRAMIDSEGMENT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PYRAMIDSEGMENT,Gstpyramidsegment))
-#define GST_PYRAMIDSEGMENT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PYRAMIDSEGMENT,GstpyramidsegmentClass))
-#define GST_IS_PYRAMIDSEGMENT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PYRAMIDSEGMENT))
-#define GST_IS_PYRAMIDSEGMENT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PYRAMIDSEGMENT))
-typedef struct _Gstpyramidsegment Gstpyramidsegment;
-typedef struct _GstpyramidsegmentClass GstpyramidsegmentClass;
-
-struct _Gstpyramidsegment
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
- gboolean silent;
-
- IplImage *cvImage, *cvSegmentedImage;
-
- CvMemStorage *storage;
-
- CvSeq *comp;
-
- double threshold1, threshold2;
-
- int level;
-};
-
-struct _GstpyramidsegmentClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_pyramidsegment_get_type (void);
-
-gboolean gst_pyramidsegment_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-#endif /* __GST_PYRAMIDSEGMENT_H__ */
+++ /dev/null
-# plugindir is set in configure
-
-noinst_LTLIBRARIES = libgsttemplatematch.la
-
-# sources used to compile this plug-in
-libgsttemplatematch_la_SOURCES = gsttemplatematch.c
-
-# flags used to compile this templatematch
-# add other _CFLAGS and _LIBS as needed
-libgsttemplatematch_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS)
-libgsttemplatematch_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
-libgsttemplatematch_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gsttemplatematch.h
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- * Copyright (C) 2009 Noam Lewis <jones.noamle@gmail.com>
- *
- * 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.
- */
-
-/**
- * SECTION:element-templatematch
- *
- * FIXME:Describe templatematch here.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch-0.10 videotestsrc ! decodebin ! ffmpegcolorspace ! templatematch template=/path/to/file.jpg ! ffmpegcolorspace ! xvimagesink
- * ]|
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gsttemplatematch.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_templatematch_debug);
-#define GST_CAT_DEFAULT gst_templatematch_debug
-
-#define DEFAULT_METHOD (3)
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_METHOD,
- PROP_TEMPLATE,
- PROP_DISPLAY,
-};
-
-/* the capabilities of the inputs and outputs.
- */
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-GST_BOILERPLATE (GstTemplateMatch, gst_templatematch, GstElement,
- GST_TYPE_ELEMENT);
-
-static void gst_templatematch_finalize (GObject * object);
-static void gst_templatematch_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_templatematch_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_templatematch_set_caps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_templatematch_chain (GstPad * pad, GstBuffer * buf);
-
-static void gst_templatematch_load_template (GstTemplateMatch * filter);
-static void gst_templatematch_match (IplImage * input, IplImage * template,
- IplImage * dist_image, double *best_res, CvPoint * best_pos, int method);
-
-/* GObject vmethod implementations */
-
-static void
-gst_templatematch_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple (element_class,
- "templatematch",
- "Filter/Effect/Video",
- "Performs template matching on videos and images, providing detected positions via bus messages",
- "Noam Lewis <jones.noamle@gmail.com>");
-
- 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));
-}
-
-/* initialize the templatematch's class */
-static void
-gst_templatematch_class_init (GstTemplateMatchClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- gobject_class->finalize = gst_templatematch_finalize;
- gobject_class->set_property = gst_templatematch_set_property;
- gobject_class->get_property = gst_templatematch_get_property;
-
- g_object_class_install_property (gobject_class, PROP_METHOD,
- g_param_spec_int ("method", "Method",
- "Specifies the way the template must be compared with image regions. 0=SQDIFF, 1=SQDIFF_NORMED, 2=CCOR, 3=CCOR_NORMED, 4=CCOEFF, 5=CCOEFF_NORMED.",
- 0, 5, DEFAULT_METHOD, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_TEMPLATE,
- g_param_spec_string ("template", "Template", "Filename of template image",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_DISPLAY,
- g_param_spec_boolean ("display", "Display",
- "Sets whether the detected template should be highlighted in the output",
- TRUE, G_PARAM_READWRITE));
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_templatematch_init (GstTemplateMatch * filter,
- GstTemplateMatchClass * gclass)
-{
- filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_templatematch_set_caps));
- gst_pad_set_getcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
- gst_pad_set_chain_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR (gst_templatematch_chain));
-
- filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_pad_set_getcaps_function (filter->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
-
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- filter->template = NULL;
- filter->display = TRUE;
- filter->cvTemplateImage = NULL;
- filter->cvDistImage = NULL;
- filter->cvImage = NULL;
- filter->method = DEFAULT_METHOD;
- gst_templatematch_load_template (filter);
-}
-
-static void
-gst_templatematch_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
-
- switch (prop_id) {
- case PROP_METHOD:
- switch (g_value_get_int (value)) {
- case 0:
- filter->method = CV_TM_SQDIFF;
- break;
- case 1:
- filter->method = CV_TM_SQDIFF_NORMED;
- break;
- case 2:
- filter->method = CV_TM_CCORR;
- break;
- case 3:
- filter->method = CV_TM_CCORR_NORMED;
- break;
- case 4:
- filter->method = CV_TM_CCOEFF;
- break;
- case 5:
- filter->method = CV_TM_CCOEFF_NORMED;
- break;
- }
- break;
- case PROP_TEMPLATE:
- filter->template = (char *) g_value_get_string (value);
- gst_templatematch_load_template (filter);
- break;
- case PROP_DISPLAY:
- filter->display = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_templatematch_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
-
- switch (prop_id) {
- case PROP_METHOD:
- g_value_set_int (value, filter->method);
- break;
- case PROP_TEMPLATE:
- g_value_set_string (value, filter->template);
- break;
- case PROP_DISPLAY:
- g_value_set_boolean (value, filter->display);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* GstElement vmethod implementations */
-
-/* this function handles the link with other elements */
-static gboolean
-gst_templatematch_set_caps (GstPad * pad, GstCaps * caps)
-{
- GstTemplateMatch *filter;
- GstPad *otherpad;
- gint width, height;
- GstStructure *structure;
-
- filter = GST_TEMPLATEMATCH (gst_pad_get_parent (pad));
- structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
- filter->cvImage =
- cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, 3);
-
- otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
- gst_object_unref (filter);
-
- return gst_pad_set_caps (otherpad, caps);
-}
-
-static void
-gst_templatematch_finalize (GObject * object)
-{
- GstTemplateMatch *filter;
- filter = GST_TEMPLATEMATCH (object);
-
- if (filter->cvImage) {
- cvReleaseImageHeader (&filter->cvImage);
- }
- if (filter->cvDistImage) {
- cvReleaseImage (&filter->cvDistImage);
- }
- if (filter->cvTemplateImage) {
- cvReleaseImage (&filter->cvTemplateImage);
- }
-}
-
-/* chain function
- * this function does the actual processing
- */
-static GstFlowReturn
-gst_templatematch_chain (GstPad * pad, GstBuffer * buf)
-{
- GstTemplateMatch *filter;
- CvPoint best_pos;
- double best_res;
-
- filter = GST_TEMPLATEMATCH (GST_OBJECT_PARENT (pad));
-
- /* FIXME Why template == NULL returns OK?
- * shouldn't it be a passthrough instead? */
- if ((!filter) || (!buf) || filter->template == NULL) {
- return GST_FLOW_OK;
- }
- filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
-
- if (!filter->cvDistImage) {
- filter->cvDistImage =
- cvCreateImage (cvSize (filter->cvImage->width -
- filter->cvTemplateImage->width + 1,
- filter->cvImage->height - filter->cvTemplateImage->height + 1),
- IPL_DEPTH_32F, 1);
- if (!filter->cvDistImage) {
- GST_WARNING ("Couldn't create dist image.");
- }
- }
- if (filter->cvTemplateImage) {
- gst_templatematch_match (filter->cvImage, filter->cvTemplateImage,
- filter->cvDistImage, &best_res, &best_pos, filter->method);
-
- GstStructure *s = gst_structure_new ("template_match",
- "x", G_TYPE_UINT, best_pos.x,
- "y", G_TYPE_UINT, best_pos.y,
- "width", G_TYPE_UINT, filter->cvTemplateImage->width,
- "height", G_TYPE_UINT, filter->cvTemplateImage->height,
- "result", G_TYPE_DOUBLE, best_res,
- NULL);
-
- GstMessage *m = gst_message_new_element (GST_OBJECT (filter), s);
- gst_element_post_message (GST_ELEMENT (filter), m);
-
- if (filter->display) {
- CvPoint corner = best_pos;
-
- buf = gst_buffer_make_writable (buf);
-
- corner.x += filter->cvTemplateImage->width;
- corner.y += filter->cvTemplateImage->height;
- cvRectangle (filter->cvImage, best_pos, corner, CV_RGB (255, 32, 32), 3,
- 8, 0);
- }
-
- }
-
- return gst_pad_push (filter->srcpad, buf);
-}
-
-
-
-static void
-gst_templatematch_match (IplImage * input, IplImage * template,
- IplImage * dist_image, double *best_res, CvPoint * best_pos, int method)
-{
- double dist_min = 0, dist_max = 0;
- CvPoint min_pos, max_pos;
- cvMatchTemplate (input, template, dist_image, method);
- cvMinMaxLoc (dist_image, &dist_min, &dist_max, &min_pos, &max_pos, NULL);
- if ((CV_TM_SQDIFF_NORMED == method) || (CV_TM_SQDIFF == method)) {
- *best_res = dist_min;
- *best_pos = min_pos;
- if (CV_TM_SQDIFF_NORMED == method) {
- *best_res = 1 - *best_res;
- }
- } else {
- *best_res = dist_max;
- *best_pos = max_pos;
- }
-}
-
-
-static void
-gst_templatematch_load_template (GstTemplateMatch * filter)
-{
- if (filter->template) {
- filter->cvTemplateImage =
- cvLoadImage (filter->template, CV_LOAD_IMAGE_COLOR);
- if (!filter->cvTemplateImage) {
- GST_WARNING ("Couldn't load template image: %s.", filter->template);
- }
- }
-}
-
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_templatematch_plugin_init (GstPlugin * templatematch)
-{
- /* debug category for fltering log messages */
- GST_DEBUG_CATEGORY_INIT (gst_templatematch_debug, "templatematch",
- 0,
- "Performs template matching on videos and images, providing detected positions via bus messages");
-
- return gst_element_register (templatematch, "templatematch", GST_RANK_NONE,
- GST_TYPE_TEMPLATEMATCH);
-}
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2008 Michael Sheldon <mike@mikeasoft.com>
- *
- * 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_TEMPLATEMATCH_H__
-#define __GST_TEMPLATEMATCH_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include <highgui.h>
-
-G_BEGIN_DECLS
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_TEMPLATEMATCH \
- (gst_templatematch_get_type())
-#define GST_TEMPLATEMATCH(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TEMPLATEMATCH,GstTemplateMatch))
-#define GST_TEMPLATEMATCH_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TEMPLATEMATCH,GstTemplateMatchClass))
-#define GST_IS_TEMPLATEMATCH(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEMPLATEMATCH))
-#define GST_IS_TEMPLATEMATCH_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEMPLATEMATCH))
-typedef struct _GstTemplateMatch GstTemplateMatch;
-typedef struct _GstTemplateMatchClass GstTemplateMatchClass;
-
-struct _GstTemplateMatch
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
- gint method;
- gboolean display;
-
- gchar *template;
-
- IplImage *cvImage, *cvGray, *cvTemplateImage, *cvDistImage;
-};
-
-struct _GstTemplateMatchClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_templatematch_get_type (void);
-
-gboolean gst_templatematch_plugin_init (GstPlugin * templatematch);
-
-G_END_DECLS
-#endif /* __GST_TEMPLATEMATCH_H__ */
+++ /dev/null
-# plugindir is set in configure
-
-noinst_LTLIBRARIES = libgsttextwrite.la
-
-# sources used to compile this plug-in
-libgsttextwrite_la_SOURCES = gsttextwrite.c
-
-# flags used to compile this textwrite
-# add other _CFLAGS and _LIBS as needed
-libgsttextwrite_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS)
-libgsttextwrite_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
-libgsttextwrite_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-# headers we need but don't want installed
-noinst_HEADERS = gsttextwrite.h
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2010 Sreerenj Balachandran <bsreerenj@gmail.com>
- *
- * 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.
- */
-
-/**
- * SECTION:element-textwrite
- *
- * FIXME:Describe textwrite here.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch -v -m fakesrc ! textwrite ! fakesink silent=TRUE
- * ]|
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gst/gst.h>
-
-#include "gsttextwrite.h"
-
-GST_DEBUG_CATEGORY_STATIC (gst_textwrite_debug);
-#define GST_CAT_DEFAULT gst_textwrite_debug
-#define DEFAULT_PROP_TEXT ""
-#define DEFAULT_PROP_WIDTH 1
-#define DEFAULT_PROP_HEIGHT 1
-#define DEFAULT_PROP_XPOS 50
-#define DEFAULT_PROP_YPOS 50
-#define DEFAULT_PROP_THICKNESS 2
-#define DEFAULT_PROP_COLOR 0
-
-
-/* Filter signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-#define DEFAULT_WIDTH 1.0
-#define DEFAULT_HEIGHT 1.0
-enum
-{
- PROP_0,
- PROP_XPOS,
- PROP_YPOS,
- PROP_THICKNESS,
- PROP_COLOR_R,
- PROP_COLOR_G,
- PROP_COLOR_B,
- PROP_TEXT,
- PROP_HEIGHT,
- PROP_WIDTH
-};
-
-/* the capabilities of the inputs and outputs.
- *
- * describe the real formats here.
- */
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
- );
-
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("ANY")
- );
-
-GST_BOILERPLATE (Gsttextwrite, gst_textwrite, GstElement,GST_TYPE_ELEMENT);
-
-static void gst_textwrite_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_textwrite_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_textwrite_set_caps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_textwrite_chain (GstPad * pad, GstBuffer * buf);
-
-
-
-/* Clean up */
-static void
-gst_textwrite_finalize (GObject * obj)
-{
- Gsttextwrite *filter = GST_textwrite (obj);
-
- if (filter->cvImage) {
- cvReleaseImage (&filter->cvImage);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (obj);
-}
-
-
-
-/* GObject vmethod implementations */
-
-static void
-gst_textwrite_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple(element_class,
- "textwrite",
- "Filter/Effect/Video",
- "Performs text writing to the video",
- "sreerenj<bsreerenj@gmail.com>");
-
- 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));
-}
-
-/* initialize the textwrite's class */
-static void
-gst_textwrite_class_init (GsttextwriteClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_textwrite_finalize);
-
- gobject_class->set_property = gst_textwrite_set_property;
- gobject_class->get_property = gst_textwrite_get_property;
-
-
- g_object_class_install_property (gobject_class, PROP_TEXT,
- g_param_spec_string ("text", "text",
- "Text to be display.", DEFAULT_PROP_TEXT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_XPOS,
- g_param_spec_int ("xpos", "horizontal position",
- "Sets the Horizontal position", 0, G_MAXINT,
- DEFAULT_PROP_XPOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_YPOS,
- g_param_spec_int ("ypos", "vertical position",
- "Sets the Vertical position", 0, G_MAXINT,
- DEFAULT_PROP_YPOS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_THICKNESS,
- g_param_spec_int ("thickness", "font thickness",
- "Sets the Thickness of Font", 0, G_MAXINT,
- DEFAULT_PROP_THICKNESS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_COLOR_R,
- g_param_spec_int ("colorR", "color -Red ",
- "Sets the color -R", 0, 255,
- DEFAULT_PROP_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_COLOR_G,
- g_param_spec_int ("colorG", "color -Green",
- "Sets the color -G", 0, 255,
- DEFAULT_PROP_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_COLOR_B,
- g_param_spec_int ("colorB", "color -Blue",
- "Sets the color -B", 0, 255,
- DEFAULT_PROP_COLOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-
-
- g_object_class_install_property (gobject_class, PROP_HEIGHT,
- g_param_spec_double ("height", "Height",
- "Sets the height of fonts",1.0,5.0,
- DEFAULT_HEIGHT, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_WIDTH,
- g_param_spec_double ("width", "Width",
- "Sets the width of fonts",1.0,5.0,
- DEFAULT_WIDTH, G_PARAM_READWRITE| G_PARAM_STATIC_STRINGS));
-
-}
-
-/* initialize the new element
- * instantiate pads and add them to element
- * set pad calback functions
- * initialize instance structure
- */
-static void
-gst_textwrite_init (Gsttextwrite * filter,
- GsttextwriteClass * gclass)
-{
- filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR(gst_textwrite_set_caps));
- gst_pad_set_getcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
- gst_pad_set_chain_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR(gst_textwrite_chain));
-
- filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_pad_set_getcaps_function (filter->srcpad,
- GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
-
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- filter->textbuf = g_strdup (DEFAULT_PROP_TEXT);
- filter->width = DEFAULT_PROP_WIDTH;
- filter->height = DEFAULT_PROP_HEIGHT;
- filter->xpos = DEFAULT_PROP_XPOS;
- filter->ypos = DEFAULT_PROP_YPOS;
- filter->thickness = DEFAULT_PROP_THICKNESS;
- filter->colorR = DEFAULT_PROP_COLOR;
- filter->colorG = DEFAULT_PROP_COLOR;
- filter->colorB = DEFAULT_PROP_COLOR;
-
-}
-
-static void
-gst_textwrite_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- Gsttextwrite *filter = GST_textwrite (object);
-
- switch (prop_id) {
- case PROP_TEXT:
- g_free (filter->textbuf);
- filter->textbuf = g_value_dup_string (value);
- break;
- case PROP_XPOS:
- filter->xpos = g_value_get_int(value);
- break;
- case PROP_YPOS:
- filter->ypos = g_value_get_int(value);
- break;
- case PROP_THICKNESS:
- filter->thickness = g_value_get_int(value);
- break;
-
- case PROP_COLOR_R:
- filter->colorR = g_value_get_int(value);
- break;
- case PROP_COLOR_G:
- filter->colorG = g_value_get_int(value);
- break;
- case PROP_COLOR_B:
- filter->colorB = g_value_get_int(value);
- break;
-
- case PROP_HEIGHT:
- filter->height = g_value_get_double(value);
- break;
- case PROP_WIDTH:
- filter->width = g_value_get_double(value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_textwrite_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- Gsttextwrite *filter = GST_textwrite (object);
-
- switch (prop_id) {
- case PROP_TEXT:
- g_value_set_string (value, filter->textbuf);
- break;
- case PROP_XPOS:
- g_value_set_int (value, filter->xpos);
- break;
- case PROP_YPOS:
- g_value_set_int (value, filter->ypos);
- break;
- case PROP_THICKNESS:
- g_value_set_int (value, filter->thickness);
- break;
- case PROP_COLOR_R:
- g_value_set_int (value, filter->colorR);
- break;
- case PROP_COLOR_G:
- g_value_set_int (value, filter->colorG);
- break;
- case PROP_COLOR_B:
- g_value_set_int (value, filter->colorB);
- break;
- case PROP_HEIGHT:
- g_value_set_double (value, filter->height);
- break;
- case PROP_WIDTH:
- g_value_set_double (value, filter->width);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* GstElement vmethod implementations */
-
-/* this function handles the link with other elements */
-static gboolean
-gst_textwrite_set_caps (GstPad * pad, GstCaps * caps)
-{
- Gsttextwrite *filter;
- GstPad *otherpad;
-
- gint width, height;
- GstStructure *structure;
-
- filter = GST_textwrite (gst_pad_get_parent (pad));
-
- structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
- filter->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
- filter->cvStorage = cvCreateMemStorage (0);
-
- otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
- gst_object_unref (filter);
-
- return gst_pad_set_caps (otherpad, caps);
-}
-
-/* chain function
- * this function does the actual processing
- */
-static GstFlowReturn
-gst_textwrite_chain (GstPad * pad, GstBuffer * buf)
-{
- Gsttextwrite *filter;
-
- filter = GST_textwrite (GST_OBJECT_PARENT (pad));
-
- filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
-
- cvInitFont(&(filter->font),CV_FONT_VECTOR0, filter->width,filter->height,0,filter->thickness,0);
-
- buf = gst_buffer_make_writable (buf);
- cvPutText (filter->cvImage,filter->textbuf,cvPoint(filter->xpos,filter->ypos), &(filter->font), cvScalar(filter->colorR,filter->colorG,filter->colorB,0));
-
- return gst_pad_push (filter->srcpad, buf);
-}
-
-
-/* entry point to initialize the plug-in
- * initialize the plug-in itself
- * register the element factories and other features
- */
-gboolean
-gst_textwrite_plugin_init (GstPlugin * plugin)
-{
- /* debug category for fltering log messages
- *
- * exchange the string 'Template textwrite' with your description
- */
- GST_DEBUG_CATEGORY_INIT (gst_textwrite_debug, "textwrite",
- 0, "Template textwrite");
-
- return gst_element_register (plugin, "textwrite", GST_RANK_NONE,
- GST_TYPE_textwrite);
-}
-
-
+++ /dev/null
-/*
- * GStreamer
- * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
- * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
- * Copyright (C) 2010 root <<user@hostname.org>>m
- *
- * 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_textwrite_H__
-#define __GST_textwrite_H__
-
-#include <gst/gst.h>
-#include <cv.h>
-#include <cvaux.h>
-#include <highgui.h>
-G_BEGIN_DECLS
-
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_textwrite \
- (gst_textwrite_get_type())
-#define GST_textwrite(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_textwrite,Gsttextwrite))
-#define GST_textwrite_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_textwrite,GsttextwriteClass))
-#define GST_IS_textwrite(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_textwrite))
-#define GST_IS_textwrite_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_textwrite))
-
-typedef struct _Gsttextwrite Gsttextwrite;
-typedef struct _GsttextwriteClass GsttextwriteClass;
-
-struct _Gsttextwrite
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
-
- IplImage *cvImage;
- CvMemStorage *cvStorage;
- CvFont font;
-
- gint xpos;
- gint ypos;
- gint thickness;
- gint colorR,colorG,colorB;
- gdouble height;
- gdouble width;
- gchar *textbuf;
-
-};
-
-struct _GsttextwriteClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_textwrite_get_type (void);
-gboolean gst_textwrite_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_textwrite_H__ */