diff --git a/CMakeLists.txt b/CMakeLists.txt index ad8c2c0..01b8808 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ find_package (Gstreamer REQUIRED) find_package (Glib2 REQUIRED) find_package (NIIMAQ) find_package (FreeImage) +find_package (OpenCV REQUIRED) # conditional required packages include (CheckIncludeFiles) @@ -22,7 +23,7 @@ endif (NOT GST_USING_BINARY_REGISTRY) include_directories ( - . + . ${GSTREAMER_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ) diff --git a/gst/CMakeLists.txt b/gst/CMakeLists.txt index b445b95..27e7a5b 100644 --- a/gst/CMakeLists.txt +++ b/gst/CMakeLists.txt @@ -1 +1,2 @@ +add_subdirectory (sensorfx) add_subdirectory (videoadjust) diff --git a/gst/sensorfx/CMakeLists.txt b/gst/sensorfx/CMakeLists.txt new file mode 100644 index 0000000..c344e2a --- /dev/null +++ b/gst/sensorfx/CMakeLists.txt @@ -0,0 +1,28 @@ +add_definitions (-DHAVE_CONFIG_H) + +set (SOURCES + gstsensorfx.c + gstsensorfx3dnoise.c) + +set (HEADERS + gstsensorfx3dnoise.h) + +include_directories ( + . + C:/gstreamer/include/gstreamer-0.10/gst/opencv + ${OpenCV_INCLUDE_DIR}) + +add_library (libgstsensorfx MODULE + ${SOURCES} + ${HEADERS}) + +target_link_libraries (libgstsensorfx + general ${GLIB2_LIBRARIES} + general ${GSTREAMER_LIBRARIES} + general ${GSTREAMER_BASE_LIBRARY} + general ${GSTREAMER_VIDEO_LIBRARY} + ${OpenCV_LIBS} + C:/gstreamer/lib/libgstopencv-0.10.lib) + +install (TARGETS libgstsensorfx + LIBRARY DESTINATION lib/gstreamer-0.10) \ No newline at end of file diff --git a/gst/sensorfx/gstsensorfx.c b/gst/sensorfx/gstsensorfx.c new file mode 100644 index 0000000..6ca5557 --- /dev/null +++ b/gst/sensorfx/gstsensorfx.c @@ -0,0 +1,36 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstsensorfx3dnoise.h" + +#define GST_CAT_DEFAULT gst_sensorfx_debug +GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); + + +/* Register filters that make up the gstsfx plugin */ +static gboolean +plugin_init (GstPlugin * plugin) +{ + GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "sensorfx", 0, "sensorfx"); + + GST_DEBUG ("plugin_init"); + + if ( !gst_element_register (plugin, "sfx3dnoise", GST_RANK_NONE, + GST_TYPE_SFX3DNOISE)) { + return FALSE; + } + + return TRUE; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "sensorfx", + "Filters to simulate the effects of real sensors", + plugin_init, + VERSION, + GST_LICENSE, + GST_PACKAGE_NAME, + GST_PACKAGE_ORIGIN + ); diff --git a/gst/sensorfx/gstsensorfx3dnoise.c b/gst/sensorfx/gstsensorfx3dnoise.c new file mode 100644 index 0000000..e1bc1de --- /dev/null +++ b/gst/sensorfx/gstsensorfx3dnoise.c @@ -0,0 +1,485 @@ +/* + * GStreamer + * Copyright (C) 2010 Thiago Santos + * + * 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 +#endif + +#include +#include + +#include "gstopencvutils.h" +#include "gstsensorfx3dnoise.h" + +GST_DEBUG_CATEGORY_STATIC (gst_sfx3dnoise_debug); +#define GST_CAT_DEFAULT gst_sfx3dnoise_debug +#define DEBUG_INIT(bla) \ + GST_DEBUG_CATEGORY_INIT (gst_sfx3dnoise_debug, "sfx3dnoise", 0, "ARF 3D-noise sensor effects"); + +/* Filter signals and args */ +enum +{ + /* FILL ME */ + LAST_SIGNAL +}; +enum +{ + PROP_0, + PROP_SIGMA_T, + PROP_SIGMA_V, + PROP_SIGMA_H, + PROP_SIGMA_TV, + PROP_SIGMA_TH, + PROP_SIGMA_VH, + PROP_SIGMA_TVH +}; + +#define DEFAULT_SIGMA_T 0.0 +#define DEFAULT_SIGMA_V 0.0 +#define DEFAULT_SIGMA_H 0.0 +#define DEFAULT_SIGMA_TV 0.0 +#define DEFAULT_SIGMA_TH 0.0 +#define DEFAULT_SIGMA_VH 0.0 +#define DEFAULT_SIGMA_TVH 0.0 + +GST_BOILERPLATE_FULL (GstSfx3DNoise, gst_sfx3dnoise, GstOpencvBaseTransform, + GST_TYPE_OPENCV_BASE_TRANSFORM, DEBUG_INIT); + +static void gst_sfx3dnoise_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_sfx3dnoise_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static GstFlowReturn gst_sfx3dnoise_cv_transform (GstOpencvBaseTransform * filter, + GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg); +static gboolean gst_sfx3dnoise_cv_set_caps (GstOpencvBaseTransform * 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); + +void gst_sfx3dnoise_create_fixed_noise (GstSfx3DNoise * filter, CvMat * arr); +void gst_sfx3dnoise_add_sigma_t (GstSfx3DNoise * filter, CvMat * arr, double sigma); +void gst_sfx3dnoise_add_sigma_tv (GstSfx3DNoise * filter, CvMat * arr, double sigma); +void gst_sfx3dnoise_add_sigma_th (GstSfx3DNoise * filter, CvMat * arr, double sigma); +void gst_sfx3dnoise_add_sigma_tvh (GstSfx3DNoise * filter, CvMat * arr, double sigma); + +/* Clean up */ +static void +gst_sfx3dnoise_finalize (GObject * obj) +{ + GstSfx3DNoise * filter = GST_SFX3DNOISE (obj); + + if (filter->fixed_noise) + cvReleaseMat (&filter->fixed_noise); + filter->fixed_noise = NULL; + + if (filter->intermediary) + cvReleaseMat (&filter->intermediary); + filter->intermediary = NULL; + + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +/* GObject vmethod implementations */ + +static void +gst_sfx3dnoise_base_init (gpointer gclass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); + GstCaps *caps; + GstPadTemplate *templ; + + /* add sink and source pad templates */ + caps = gst_caps_from_string (GST_VIDEO_CAPS_GRAY16("1234")); + templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, + gst_caps_ref (caps)); + gst_element_class_add_pad_template (element_class, templ); + templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps); + gst_element_class_add_pad_template (element_class, templ); + + gst_element_class_set_details_simple (element_class, + "sfx3dnoise", + "Transform/Effect/Video", + "Add 3D noise to video", + "Joshua M. Doe "); +} + +static void +gst_sfx3dnoise_class_init (GstSfx3DNoiseClass * klass) +{ + GObjectClass *gobject_class; + GstBaseTransformClass *gstbasetransform_class; + GstOpencvBaseTransformClass *gstopencvbasefilter_class; + GstElementClass *gstelement_class; + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + gstbasetransform_class = (GstBaseTransformClass *) klass; + gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_sfx3dnoise_finalize); + gobject_class->set_property = gst_sfx3dnoise_set_property; + gobject_class->get_property = gst_sfx3dnoise_get_property; + + gstopencvbasefilter_class->cv_trans_func = gst_sfx3dnoise_cv_transform; + gstopencvbasefilter_class->cv_set_caps = gst_sfx3dnoise_cv_set_caps; + + g_object_class_install_property (gobject_class, PROP_SIGMA_T, + g_param_spec_double ("sigma-t", "sigma-t", + "Adds frame to frame noise or bounce (flicker)", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); + + g_object_class_install_property (gobject_class, PROP_SIGMA_V, + g_param_spec_double ("sigma-v", "sigma-v", + "Adds fixed row noise (horizontal lines)", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); + + g_object_class_install_property (gobject_class, PROP_SIGMA_H, + g_param_spec_double ("sigma-h", "sigma-h", + "Adds fixed column noise (vertical lines)", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); + + g_object_class_install_property (gobject_class, PROP_SIGMA_TV, + g_param_spec_double ("sigma-tv", "sigma-tv", + "Adds temporal row bounce (random horizontal lines)", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); + + g_object_class_install_property (gobject_class, PROP_SIGMA_TH, + g_param_spec_double ("sigma-th", "sigma-th", + "Adds temporal column bounce (random vertical lines)", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); + + g_object_class_install_property (gobject_class, PROP_SIGMA_VH, + g_param_spec_double ("sigma-vh", "sigma-vh", + "Adds random time-independent spatial noise (fixed pattern noise)", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); + + g_object_class_install_property (gobject_class, PROP_SIGMA_TVH, + g_param_spec_double ("sigma-tvh", "sigma-tvh", + "Adds random spatio-temporal noise", + 0.0, 1.0, DEFAULT_SIGMA_T, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) + ); +} + +static void +gst_sfx3dnoise_init (GstSfx3DNoise * filter, GstSfx3DNoiseClass * gclass) +{ + GST_DEBUG ("Initializing"); + + filter->sigma_t = DEFAULT_SIGMA_T; + filter->sigma_v = filter->sigma_v_old = DEFAULT_SIGMA_V; + filter->sigma_h = filter->sigma_h_old = DEFAULT_SIGMA_H; + filter->sigma_tv = DEFAULT_SIGMA_TV; + filter->sigma_th = DEFAULT_SIGMA_TH; + filter->sigma_vh = filter->sigma_vh_old = DEFAULT_SIGMA_VH; + filter->sigma_tvh = DEFAULT_SIGMA_TVH; + + filter->rng = cvRNG(-1); + filter->fixed_noise = NULL; + filter->intermediary = NULL; + + filter->width = 0; + filter->height = 0; + + gst_base_transform_set_in_place (GST_BASE_TRANSFORM (filter), TRUE); +} + +static void +gst_sfx3dnoise_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstSfx3DNoise *filter = GST_SFX3DNOISE (object); + + switch (prop_id) { + case PROP_SIGMA_T: + filter->sigma_t= g_value_get_double (value); + break; + case PROP_SIGMA_V: + filter->sigma_v= g_value_get_double (value); + break; + case PROP_SIGMA_H: + filter->sigma_h= g_value_get_double (value); + break; + case PROP_SIGMA_TV: + filter->sigma_tv= g_value_get_double (value); + break; + case PROP_SIGMA_TH: + filter->sigma_th= g_value_get_double (value); + break; + case PROP_SIGMA_VH: + filter->sigma_vh= g_value_get_double (value); + break; + case PROP_SIGMA_TVH: + filter->sigma_tvh= g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_sfx3dnoise_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstSfx3DNoise *filter = GST_SFX3DNOISE (object); + + switch (prop_id) { + case PROP_SIGMA_T: + g_value_set_double (value, filter->sigma_t); + break; + case PROP_SIGMA_V: + g_value_set_double (value, filter->sigma_v); + break; + case PROP_SIGMA_H: + g_value_set_double (value, filter->sigma_h); + break; + case PROP_SIGMA_TV: + g_value_set_double (value, filter->sigma_tv); + break; + case PROP_SIGMA_TH: + g_value_set_double (value, filter->sigma_th); + break; + case PROP_SIGMA_VH: + g_value_set_double (value, filter->sigma_vh); + break; + case PROP_SIGMA_TVH: + g_value_set_double (value, filter->sigma_tvh); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GstFlowReturn +gst_sfx3dnoise_cv_transform (GstOpencvBaseTransform * base, GstBuffer * buf, + IplImage * img, GstBuffer * outbuf, IplImage * outimg) +{ + GstSfx3DNoise *filter = GST_SFX3DNOISE (base); + + GST_DEBUG ("Transforming"); + + cvConvert (img, filter->intermediary); + + if (filter->sigma_h != filter->sigma_h_old || + filter->sigma_v != filter->sigma_v_old || + filter->sigma_vh != filter->sigma_vh_old) { + GST_DEBUG ("Creating new fixed pattern noise image"); + gst_sfx3dnoise_create_fixed_noise (filter, filter->fixed_noise); + + filter->sigma_h_old = filter->sigma_h; + filter->sigma_v_old = filter->sigma_v; + filter->sigma_vh_old = filter->sigma_vh; + } + + if (filter->sigma_h != 0.0 || filter->sigma_v != 0.0 || filter->sigma_vh != 0.0) { + cvAdd (filter->intermediary, filter->fixed_noise, filter->intermediary, 0); + } + + if (filter->sigma_tvh > 0.0) { + gst_sfx3dnoise_add_sigma_tvh (filter, filter->intermediary, filter->sigma_tvh); + } + + if (filter->sigma_tv > 0.0) { + gst_sfx3dnoise_add_sigma_tv (filter, filter->intermediary, filter->sigma_tv); + } + + if (filter->sigma_th > 0.0) { + gst_sfx3dnoise_add_sigma_th (filter, filter->intermediary, filter->sigma_th); + } + + if (filter->sigma_t > 0.0) { + gst_sfx3dnoise_add_sigma_t (filter, filter->intermediary, filter->sigma_t); + } + + cvConvert (filter->intermediary, outimg); + + return GST_FLOW_OK; +} + +static gboolean +gst_sfx3dnoise_cv_set_caps (GstOpencvBaseTransform * 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) +{ + GstSfx3DNoise *filter = GST_SFX3DNOISE (trans); + + GST_DEBUG ("Caps have been set"); + + filter->width = in_width; + filter->height = in_height; + + if (filter->intermediary) { + cvReleaseMat (&filter->intermediary); + filter->intermediary = NULL; + } + + if (out_depth != IPL_DEPTH_32F) { + filter->intermediary = cvCreateMat (out_height, out_width, CV_32FC1); + } + + if (filter->fixed_noise) { + cvReleaseMat (&filter->fixed_noise); + filter->fixed_noise = NULL; + } + filter->fixed_noise = cvCreateMat (out_height, out_width, CV_32FC1); + gst_sfx3dnoise_create_fixed_noise (filter, filter->fixed_noise); + + + + /* TODO create fixed noise here */ + + return TRUE; +} + +gboolean +gst_sfx3dnoise_plugin_init (GstPlugin * plugin) +{ + GST_DEBUG ("Initializing plugin sfx3dnoise"); + + return gst_element_register (plugin, "sfx3dnoise", GST_RANK_NONE, + GST_TYPE_SFX3DNOISE); +} + +void +gst_sfx3dnoise_create_fixed_noise (GstSfx3DNoise * filter, CvMat * arr) +{ + cvZero (arr); + gst_sfx3dnoise_add_sigma_tvh (filter, arr, filter->sigma_vh); + gst_sfx3dnoise_add_sigma_th (filter, arr, filter->sigma_h); + gst_sfx3dnoise_add_sigma_tv (filter, arr, filter->sigma_v); +} + +/* Add sigma-vh or sigma-tvh noise, which adds random noise to every pixel */ +void +gst_sfx3dnoise_add_sigma_tvh (GstSfx3DNoise * filter, CvMat * arr, double sigma) { + CvMat * noise = cvCreateMat (filter->height, filter->width, CV_32F); + + /* TODO move scaling of sigma somewhere else? */ + cvRandArr (&filter->rng, noise, CV_RAND_NORMAL, cvScalarAll (0), + cvScalarAll (sigma*(G_MAXUINT16-1))); + + cvAdd (arr, noise, arr, 0); + + cvReleaseMat (&noise); +} + + +/* Add sigma-v or sigma-tv noise, which adds random horizontal lines */ +void +gst_sfx3dnoise_add_sigma_tv (GstSfx3DNoise * filter, CvMat * arr, double sigma) { + CvMat * noise = cvCreateMat (1, filter->height, CV_32F); + gfloat * data; + gfloat * noisedata; + int step, x, y; + + /* TODO move scaling of sigma somewhere else? */ + cvRandArr (&filter->rng, noise, CV_RAND_NORMAL, cvScalarAll (0), + cvScalarAll (sigma*(G_MAXUINT16-1))); + + cvGetRawData (arr, (uchar**)&data, &step, NULL); + cvGetRawData (noise, (uchar**)&noisedata, NULL, NULL); + + step /= sizeof(gfloat); + + for (y = 0; y < filter->height; y++) { + for (x = 0; x < filter->width; x++) { + data[y*step + x] += noisedata[y]; + } + } + + cvReleaseMat (&noise); +} + + +/* Add sigma-h and sigma-th noise, which adds random vertical lines */ +void +gst_sfx3dnoise_add_sigma_th (GstSfx3DNoise * filter, CvMat * arr, double sigma) { + CvMat * noise = cvCreateMat (1, filter->width, CV_32F); + gfloat * data; + gfloat * noisedata; + int step, x, y; + + /* TODO move scaling of sigma somewhere else? */ + cvRandArr (&filter->rng, noise, CV_RAND_NORMAL, cvScalarAll (0), + cvScalarAll (sigma*(G_MAXUINT16-1))); + + cvGetRawData (arr, (uchar**)&data, &step, NULL); + cvGetRawData (noise, (uchar**)&noisedata, NULL, NULL); + + step /= sizeof(gfloat); + + for (y = 0; y < filter->height; y++) { + for (x = 0; x < filter->width; x++) { + data[y*step + x] += noisedata[x]; + } + } + + cvReleaseMat (&noise); +} + +/* Add Sigma_T noise, which creates a flashing effect */ +void +gst_sfx3dnoise_add_sigma_t (GstSfx3DNoise * filter, CvMat * arr, double sigma) +{ + CvMat * noise = cvCreateMat (1, 1, CV_32F); + float * data; + + /* TODO move scaling of sigma somewhere else? */ + cvRandArr (&filter->rng, noise, CV_RAND_NORMAL, cvScalarAll (0), + cvScalarAll (sigma*(G_MAXUINT16-1))); + + cvGetRawData (noise, (uchar**)&data, NULL, NULL); + + cvAddS (arr, cvScalarAll (*data), arr, 0); + + cvReleaseMat (&noise); +} \ No newline at end of file diff --git a/gst/sensorfx/gstsensorfx3dnoise.h b/gst/sensorfx/gstsensorfx3dnoise.h new file mode 100644 index 0000000..6aab460 --- /dev/null +++ b/gst/sensorfx/gstsensorfx3dnoise.h @@ -0,0 +1,103 @@ +/* + * GStreamer + * Copyright (C) 2010 Thiago Santos + * + * 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_SFX3DNOISE_H__ +#define __GST_SFX3DNOISE_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +/* #defines don't like whitespacey bits */ +#define GST_TYPE_SFX3DNOISE \ + (gst_sfx3dnoise_get_type()) +#define GST_SFX3DNOISE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SFX3DNOISE,GstSfx3DNoise)) +#define GST_SFX3DNOISE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SFX3DNOISE,GstSfx3DNoiseClass)) +#define GST_IS_SFX3DNOISE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SFX3DNOISE)) +#define GST_IS_SFX3DNOISE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SFX3DNOISE)) + +typedef struct _GstSfx3DNoise GstSfx3DNoise; +typedef struct _GstSfx3DNoiseClass GstSfx3DNoiseClass; + +struct _GstSfx3DNoise +{ + GstOpencvBaseTransform element; + + gdouble sigma_t; + gdouble sigma_v; + gdouble sigma_h; + gdouble sigma_tv; + gdouble sigma_th; + gdouble sigma_vh; + gdouble sigma_tvh; + + gdouble sigma_v_old; + gdouble sigma_h_old; + gdouble sigma_vh_old; + + gint width; + gint height; + + CvRNG rng; + CvMat * fixed_noise; + CvMat * intermediary; +}; + +struct _GstSfx3DNoiseClass +{ + GstOpencvBaseTransformClass parent_class; +}; + +GType gst_sfx3dnoise_get_type (void); + +gboolean gst_sfx3dnoise_plugin_init (GstPlugin * plugin); + +G_END_DECLS + +#endif /* __GST_SFX3DNOISE_H__ */