mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 13:08:49 +00:00
opencv: switch deprecated cvSmooth for GaussianBlur
The OpenCV cvSmooth function is deprecated [0] and the documentation recommends to use GaussianBlur (). This makes the spatial property go unused. Marking it as deprecated, making it non-functional and will remove in the next cycle. [0] http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html
This commit is contained in:
parent
052f41e5c2
commit
ad1b36321a
2 changed files with 19 additions and 30 deletions
|
@ -60,11 +60,13 @@
|
||||||
|
|
||||||
#include "gstopencvutils.h"
|
#include "gstopencvutils.h"
|
||||||
#include "gstcvsmooth.h"
|
#include "gstcvsmooth.h"
|
||||||
#include <opencv2/imgproc/imgproc_c.h>
|
#include <opencv2/imgproc/imgproc.hpp>
|
||||||
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_cv_smooth_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_cv_smooth_debug);
|
||||||
#define GST_CAT_DEFAULT gst_cv_smooth_debug
|
#define GST_CAT_DEFAULT gst_cv_smooth_debug
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
/* Filter signals and args */
|
/* Filter signals and args */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -114,7 +116,7 @@ gst_cv_smooth_type_get_type (void)
|
||||||
|
|
||||||
#define DEFAULT_CV_SMOOTH_TYPE CV_GAUSSIAN
|
#define DEFAULT_CV_SMOOTH_TYPE CV_GAUSSIAN
|
||||||
#define DEFAULT_WIDTH 3
|
#define DEFAULT_WIDTH 3
|
||||||
#define DEFAULT_HEIGHT 0
|
#define DEFAULT_HEIGHT 3
|
||||||
#define DEFAULT_COLORSIGMA 0.0
|
#define DEFAULT_COLORSIGMA 0.0
|
||||||
#define DEFAULT_SPATIALSIGMA 0.0
|
#define DEFAULT_SPATIALSIGMA 0.0
|
||||||
|
|
||||||
|
@ -157,33 +159,24 @@ gst_cv_smooth_class_init (GstCvSmoothClass * klass)
|
||||||
DEFAULT_CV_SMOOTH_TYPE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))
|
DEFAULT_CV_SMOOTH_TYPE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))
|
||||||
);
|
);
|
||||||
g_object_class_install_property (gobject_class, PROP_WIDTH,
|
g_object_class_install_property (gobject_class, PROP_WIDTH,
|
||||||
g_param_spec_int ("width", "width (aperture width)",
|
g_param_spec_int ("width", "width (kernel width)",
|
||||||
"The aperture width (Must be positive and odd)."
|
"The gaussian kernel width (must be positive and odd).",
|
||||||
"Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
|
1, G_MAXINT, DEFAULT_WIDTH,
|
||||||
"/documentation/image_filtering.html#cvSmooth", 1, G_MAXINT,
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
DEFAULT_WIDTH, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
|
||||||
g_object_class_install_property (gobject_class, PROP_HEIGHT,
|
g_object_class_install_property (gobject_class, PROP_HEIGHT,
|
||||||
g_param_spec_int ("height", "height (aperture height)",
|
g_param_spec_int ("height", "height (kernel height)",
|
||||||
"The aperture height, if zero, the width is used."
|
"The gaussian kernel height (must be positive and odd).",
|
||||||
"(Must be positive and odd or zero, unuset in median and bilateral "
|
0, G_MAXINT, DEFAULT_HEIGHT,
|
||||||
"types). Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
"/documentation/image_filtering.html#cvSmooth", 0, G_MAXINT,
|
|
||||||
DEFAULT_HEIGHT, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
|
||||||
g_object_class_install_property (gobject_class, PROP_COLORSIGMA,
|
g_object_class_install_property (gobject_class, PROP_COLORSIGMA,
|
||||||
g_param_spec_double ("color", "color (gaussian standard deviation or "
|
g_param_spec_double ("color", "color (gaussian standard deviation or "
|
||||||
"color sigma",
|
"color sigma",
|
||||||
"If type is gaussian, this means the standard deviation."
|
"Gaussian kernel standard deviation in X and Y direction",
|
||||||
"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_COLORSIGMA,
|
0, G_MAXDOUBLE, DEFAULT_COLORSIGMA,
|
||||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
g_object_class_install_property (gobject_class, PROP_SPATIALSIGMA,
|
g_object_class_install_property (gobject_class, PROP_SPATIALSIGMA,
|
||||||
g_param_spec_double ("spatial", "spatial (spatial sigma, bilateral only)",
|
g_param_spec_double ("spatial", "spatial (spatial sigma, bilateral only)",
|
||||||
"Only used in bilateral type, means the spatial-sigma."
|
"(DEPRECATED: value not used anymore)",
|
||||||
"Check cvSmooth OpenCV docs: http://opencv.willowgarage.com"
|
|
||||||
"/documentation/image_filtering.html#cvSmooth",
|
|
||||||
0, G_MAXDOUBLE, DEFAULT_SPATIALSIGMA,
|
0, G_MAXDOUBLE, DEFAULT_SPATIALSIGMA,
|
||||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
|
|
||||||
|
@ -215,7 +208,6 @@ gst_cv_smooth_init (GstCvSmooth * filter)
|
||||||
filter->width = DEFAULT_WIDTH;
|
filter->width = DEFAULT_WIDTH;
|
||||||
filter->height = DEFAULT_HEIGHT;
|
filter->height = DEFAULT_HEIGHT;
|
||||||
filter->colorsigma = DEFAULT_COLORSIGMA;
|
filter->colorsigma = DEFAULT_COLORSIGMA;
|
||||||
filter->spatialsigma = DEFAULT_SPATIALSIGMA;
|
|
||||||
|
|
||||||
gst_opencv_video_filter_set_in_place (GST_OPENCV_VIDEO_FILTER_CAST (filter),
|
gst_opencv_video_filter_set_in_place (GST_OPENCV_VIDEO_FILTER_CAST (filter),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -266,7 +258,7 @@ gst_cv_smooth_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_HEIGHT:{
|
case PROP_HEIGHT:{
|
||||||
gint prop = g_value_get_int (value);
|
gint prop = g_value_get_int (value);
|
||||||
|
|
||||||
if (prop % 2 == 1 || prop == 0) {
|
if (prop % 2 == 1) {
|
||||||
filter->height = prop;
|
filter->height = prop;
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING_OBJECT (filter, "Ignoring value for height, not odd"
|
GST_WARNING_OBJECT (filter, "Ignoring value for height, not odd"
|
||||||
|
@ -278,7 +270,6 @@ gst_cv_smooth_set_property (GObject * object, guint prop_id,
|
||||||
filter->colorsigma = g_value_get_double (value);
|
filter->colorsigma = g_value_get_double (value);
|
||||||
break;
|
break;
|
||||||
case PROP_SPATIALSIGMA:
|
case PROP_SPATIALSIGMA:
|
||||||
filter->spatialsigma = g_value_get_double (value);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -306,7 +297,6 @@ gst_cv_smooth_get_property (GObject * object, guint prop_id,
|
||||||
g_value_set_double (value, filter->colorsigma);
|
g_value_set_double (value, filter->colorsigma);
|
||||||
break;
|
break;
|
||||||
case PROP_SPATIALSIGMA:
|
case PROP_SPATIALSIGMA:
|
||||||
g_value_set_double (value, filter->spatialsigma);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -320,8 +310,8 @@ gst_cv_smooth_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
|
||||||
{
|
{
|
||||||
GstCvSmooth *filter = GST_CV_SMOOTH (base);
|
GstCvSmooth *filter = GST_CV_SMOOTH (base);
|
||||||
|
|
||||||
cvSmooth (img, outimg, filter->type, filter->width, filter->height,
|
GaussianBlur (Mat (img), Mat (outimg), Size (filter->width, filter->height),
|
||||||
filter->colorsigma, filter->spatialsigma);
|
filter->colorsigma, filter->colorsigma);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
@ -332,8 +322,8 @@ gst_cv_smooth_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
|
||||||
{
|
{
|
||||||
GstCvSmooth *filter = GST_CV_SMOOTH (base);
|
GstCvSmooth *filter = GST_CV_SMOOTH (base);
|
||||||
|
|
||||||
cvSmooth (img, img, filter->type, filter->width, filter->height,
|
GaussianBlur (Mat (img), Mat (img), Size (filter->width, filter->height),
|
||||||
filter->colorsigma, filter->spatialsigma);
|
filter->colorsigma, filter->colorsigma);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@ struct _GstCvSmooth
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
gdouble colorsigma;
|
gdouble colorsigma;
|
||||||
gdouble spatialsigma;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstCvSmoothClass
|
struct _GstCvSmoothClass
|
||||||
|
|
Loading…
Reference in a new issue