summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/opencv/gstcvdilateerode.c34
-rw-r--r--ext/opencv/gstcvequalizehist.c5
-rw-r--r--ext/opencv/gstcvlaplace.c20
-rw-r--r--ext/opencv/gstcvsmooth.c33
-rw-r--r--ext/opencv/gstcvsobel.c20
-rw-r--r--ext/opencv/gstedgedetect.c5
-rw-r--r--ext/opencv/gstfaceblur.c5
-rw-r--r--ext/opencv/gstopencvutils.c30
-rw-r--r--ext/opencv/gstopencvutils.h4
-rw-r--r--ext/opencv/gstpyramidsegment.c5
-rw-r--r--ext/opencv/gsttemplatematch.c5
-rw-r--r--ext/opencv/gsttextwrite.c5
12 files changed, 112 insertions, 59 deletions
diff --git a/ext/opencv/gstcvdilateerode.c b/ext/opencv/gstcvdilateerode.c
index c304a4ffa..8b689f21b 100644
--- a/ext/opencv/gstcvdilateerode.c
+++ b/ext/opencv/gstcvdilateerode.c
@@ -52,6 +52,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstcvdilateerode.h"
/*
@@ -59,19 +60,6 @@ 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
@@ -143,11 +131,21 @@ 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));
+ GstCaps *caps;
+ GstPadTemplate *templ;
+
+ /* add sink and source pad templates */
+ caps = gst_opencv_caps_from_cv_image_type (CV_16UC1);
+ gst_caps_append (caps, gst_opencv_caps_from_cv_image_type (CV_8UC4));
+ gst_caps_append (caps, gst_opencv_caps_from_cv_image_type (CV_8UC3));
+ gst_caps_append (caps, gst_opencv_caps_from_cv_image_type (CV_8UC1));
+ 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);
+ gst_object_unref (templ);
+ templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
+ gst_element_class_add_pad_template (element_class, templ);
+ gst_object_unref (templ);
}
/* initialize the cvdilate_erode's class */
diff --git a/ext/opencv/gstcvequalizehist.c b/ext/opencv/gstcvequalizehist.c
index 9e2b0306e..9f2ebf2a2 100644
--- a/ext/opencv/gstcvequalizehist.c
+++ b/ext/opencv/gstcvequalizehist.c
@@ -47,6 +47,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstcvequalizehist.h"
GST_DEBUG_CATEGORY_STATIC (gst_cv_equalize_hist_debug);
@@ -55,12 +56,12 @@ GST_DEBUG_CATEGORY_STATIC (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"));
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8));
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_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8));
GST_BOILERPLATE (GstCvEqualizeHist, gst_cv_equalize_hist,
GstOpencvVideoFilter, GST_TYPE_OPENCV_VIDEO_FILTER);
diff --git a/ext/opencv/gstcvlaplace.c b/ext/opencv/gstcvlaplace.c
index f52842871..eddcbb12c 100644
--- a/ext/opencv/gstcvlaplace.c
+++ b/ext/opencv/gstcvlaplace.c
@@ -47,6 +47,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstcvlaplace.h"
GST_DEBUG_CATEGORY_STATIC (gst_cv_laplace_debug);
@@ -55,14 +56,19 @@ GST_DEBUG_CATEGORY_STATIC (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")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8)
);
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ #define BYTE_ORDER_STRING "BIG_ENDIAN"
+#else
+ #define BYTE_ORDER_STRING "LITTLE_ENDIAN"
+#endif
+
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")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY16 (BYTE_ORDER_STRING))
);
/* Filter signals and args */
@@ -213,14 +219,18 @@ gst_cv_laplace_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
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);
+ "bpp", G_TYPE_INT, 16,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ 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);
+ "depth", G_TYPE_INT, 8,
+ "bpp", G_TYPE_INT, 8,
+ NULL);
gst_structure_remove_field (structure, "endianness");
}
break;
diff --git a/ext/opencv/gstcvsmooth.c b/ext/opencv/gstcvsmooth.c
index 46d880dc6..62f54b27f 100644
--- a/ext/opencv/gstcvsmooth.c
+++ b/ext/opencv/gstcvsmooth.c
@@ -47,25 +47,12 @@
#include <gst/gst.h>
+#include "gstopencvutils.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
{
@@ -146,17 +133,25 @@ 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));
+ GstCaps *caps;
+ GstPadTemplate *templ;
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>");
+
+ /* add sink and source pad templates */
+ caps = gst_opencv_caps_from_cv_image_type (CV_8UC3);
+ gst_caps_append (caps, gst_opencv_caps_from_cv_image_type (CV_8UC1));
+ 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);
+ gst_object_unref (templ);
+ templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
+ gst_element_class_add_pad_template (element_class, templ);
+ gst_object_unref (templ);
}
/* initialize the cvsmooth's class */
diff --git a/ext/opencv/gstcvsobel.c b/ext/opencv/gstcvsobel.c
index eaeeeb804..9ee55d915 100644
--- a/ext/opencv/gstcvsobel.c
+++ b/ext/opencv/gstcvsobel.c
@@ -47,6 +47,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstcvsobel.h"
GST_DEBUG_CATEGORY_STATIC (gst_cv_sobel_debug);
@@ -55,14 +56,19 @@ GST_DEBUG_CATEGORY_STATIC (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")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8)
);
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ #define BYTE_ORDER_STRING "BIG_ENDIAN"
+#else
+ #define BYTE_ORDER_STRING "LITTLE_ENDIAN"
+#endif
+
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")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY16 (BYTE_ORDER_STRING))
);
/* Filter signals and args */
@@ -188,14 +194,18 @@ gst_cv_sobel_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
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);
+ "bpp", G_TYPE_INT, 16,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ 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);
+ "depth", G_TYPE_INT, 8,
+ "bpp", G_TYPE_INT, 8,
+ NULL);
gst_structure_remove_field (structure, "endianness");
}
break;
diff --git a/ext/opencv/gstedgedetect.c b/ext/opencv/gstedgedetect.c
index 19094eae6..f6d90e09b 100644
--- a/ext/opencv/gstedgedetect.c
+++ b/ext/opencv/gstedgedetect.c
@@ -62,6 +62,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstedgedetect.h"
GST_DEBUG_CATEGORY_STATIC (gst_edgedetect_debug);
@@ -90,13 +91,13 @@ enum
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
GST_BOILERPLATE (Gstedgedetect, gst_edgedetect, GstElement, GST_TYPE_ELEMENT);
diff --git a/ext/opencv/gstfaceblur.c b/ext/opencv/gstfaceblur.c
index ddbfcdc28..8f901af90 100644
--- a/ext/opencv/gstfaceblur.c
+++ b/ext/opencv/gstfaceblur.c
@@ -62,6 +62,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstfaceblur.h"
GST_DEBUG_CATEGORY_STATIC (gst_faceblur_debug);
@@ -87,13 +88,13 @@ enum
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
GST_BOILERPLATE (Gstfaceblur, gst_faceblur, GstElement, GST_TYPE_ELEMENT);
diff --git a/ext/opencv/gstopencvutils.c b/ext/opencv/gstopencvutils.c
index 0dbdde3f3..1f5502a15 100644
--- a/ext/opencv/gstopencvutils.c
+++ b/ext/opencv/gstopencvutils.c
@@ -92,3 +92,33 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width,
gst_opencv_parse_iplimage_params_from_structure (gst_caps_get_structure
(caps, 0), width, height, ipldepth, channels, err);
}
+
+GstCaps *
+gst_opencv_caps_from_cv_image_type (int cv_type)
+{
+ GstCaps * caps = gst_caps_new_empty ();
+ switch (cv_type) {
+ case CV_8UC1:
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_GRAY8));
+ break;
+ case CV_8UC3:
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGB));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGR));
+ break;
+ case CV_8UC4:
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBx));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xRGB));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRx));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xBGR));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBA));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ARGB));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRA));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ABGR));
+ break;
+ case CV_16UC1:
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_GRAY16("1234")));
+ gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_GRAY16("4321")));
+ break;
+ }
+ return caps;
+} \ No newline at end of file
diff --git a/ext/opencv/gstopencvutils.h b/ext/opencv/gstopencvutils.h
index d4602a7c6..66efac71b 100644
--- a/ext/opencv/gstopencvutils.h
+++ b/ext/opencv/gstopencvutils.h
@@ -27,6 +27,8 @@
#endif
#include <gst/gst.h>
+#include <gst/video/video.h>
+
#include <cv.h>
gboolean
@@ -39,4 +41,6 @@ gboolean gst_opencv_parse_iplimage_params_from_structure
(GstStructure * structure, gint * width, gint * height, gint * depth,
gint * channels, GError ** err);
+GstCaps * gst_opencv_caps_from_cv_image_type (int cv_type);
+
#endif /* __GST_OPENCV_UTILS__ */
diff --git a/ext/opencv/gstpyramidsegment.c b/ext/opencv/gstpyramidsegment.c
index 53bdfd207..760c57134 100644
--- a/ext/opencv/gstpyramidsegment.c
+++ b/ext/opencv/gstpyramidsegment.c
@@ -62,6 +62,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gstpyramidsegment.h"
#define BLOCK_SIZE 1000
@@ -92,13 +93,13 @@ enum
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
GST_BOILERPLATE (Gstpyramidsegment, gst_pyramidsegment, GstElement,
diff --git a/ext/opencv/gsttemplatematch.c b/ext/opencv/gsttemplatematch.c
index f8fde9c3d..8e96d1ac1 100644
--- a/ext/opencv/gsttemplatematch.c
+++ b/ext/opencv/gsttemplatematch.c
@@ -63,6 +63,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gsttemplatematch.h"
GST_DEBUG_CATEGORY_STATIC (gst_templatematch_debug);
@@ -90,13 +91,13 @@ enum
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
GST_BOILERPLATE (GstTemplateMatch, gst_templatematch, GstElement,
diff --git a/ext/opencv/gsttextwrite.c b/ext/opencv/gsttextwrite.c
index 947c723f8..0a84bbab4 100644
--- a/ext/opencv/gsttextwrite.c
+++ b/ext/opencv/gsttextwrite.c
@@ -62,6 +62,7 @@
#include <gst/gst.h>
+#include "gstopencvutils.h"
#include "gsttextwrite.h"
GST_DEBUG_CATEGORY_STATIC (gst_textwrite_debug);
@@ -104,13 +105,13 @@ enum
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("ANY")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
GST_BOILERPLATE (Gsttextwrite, gst_textwrite, GstElement, GST_TYPE_ELEMENT);