opencvbasetrans: Use GstVideoFilter as the base class

Port from GstBaseTransform to GstVideoFilter as the base class.
This commit is contained in:
Thiago Santos 2010-09-03 20:27:31 -03:00
parent 4c03c980ce
commit dcb97354bf
16 changed files with 159 additions and 174 deletions

View file

@ -5,11 +5,12 @@ SUBDIRS = basicfilters edgedetect faceblur facedetect pyramidsegment templatemat
plugin_LTLIBRARIES = libgstopencv.la
# sources used to compile this plug-in
libgstopencv_la_SOURCES = gstopencv.c gstopencvbasetrans.c gstopencvutils.c
libgstopencv_la_SOURCES = gstopencv.c gstopencvvideofilter.c gstopencvutils.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}/src \
-I${top_srcdir}/ext/opencv/basicfilters \
-I${top_srcdir}/ext/opencv/edgedetect \
@ -20,13 +21,14 @@ libgstopencv_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(OPENCV_CFLAGS) \
-I${top_srcdir}/ext/opencv/textwrite
libgstopencv_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(OPENCV_LIBS) \
$(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) \
$(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
libgstopencv_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
@ -40,4 +42,4 @@ libgstopencv_la_DEPENDENCIES = \
$(top_builddir)/ext/opencv/textwrite/libgsttextwrite.la
# headers we need but don't want installed
noinst_HEADERS = gstopencvbasetrans.h gstopencvutils.h
noinst_HEADERS = gstopencvvideofilter.h gstopencvutils.h

View file

@ -11,8 +11,11 @@ libgstbasicfilters_la_SOURCES = gstcvsmooth.c \
# flags used to compile this pyramidsegment
# add other _CFLAGS and _LIBS as needed
libgstbasicfilters_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS) -I..
libgstbasicfilters_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
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

View file

@ -55,9 +55,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_cv_dilate_debug);
GST_BOILERPLATE (GstCvDilate, gst_cv_dilate, GstCvDilateErode,
GST_TYPE_CV_DILATE_ERODE);
static GstFlowReturn gst_cv_dilate_transform_ip (GstOpencvBaseTransform *
static GstFlowReturn gst_cv_dilate_transform_ip (GstOpencvVideoFilter *
filter, GstBuffer * buf, IplImage * img);
static GstFlowReturn gst_cv_dilate_transform (GstOpencvBaseTransform * filter,
static GstFlowReturn gst_cv_dilate_transform (GstOpencvVideoFilter * filter,
GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
/* GObject vmethod implementations */
@ -77,9 +77,9 @@ gst_cv_dilate_base_init (gpointer gclass)
static void
gst_cv_dilate_class_init (GstCvDilateClass * klass)
{
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@ -98,7 +98,7 @@ gst_cv_dilate_init (GstCvDilate * filter, GstCvDilateClass * gclass)
}
static GstFlowReturn
gst_cv_dilate_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_dilate_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
@ -110,7 +110,7 @@ gst_cv_dilate_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
}
static GstFlowReturn
gst_cv_dilate_transform_ip (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_dilate_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img)
{
GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);

View file

@ -118,7 +118,7 @@ gst_cv_dilate_erode_get_type (void)
(GInstanceInitFunc) gst_cv_dilate_erode_init,
};
_type = g_type_register_static (GST_TYPE_OPENCV_BASE_TRANSFORM,
_type = g_type_register_static (GST_TYPE_OPENCV_VIDEO_FILTER,
"GstCvDilateErode", &opencv_dilate_erode_info,
G_TYPE_FLAG_ABSTRACT);
/*
@ -156,12 +156,12 @@ static void
gst_cv_dilate_erode_class_init (GstCvDilateErodeClass * klass)
{
GObjectClass *gobject_class;
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);

View file

@ -46,7 +46,7 @@
#include <gst/gst.h>
#include <cv.h>
#include <gstopencvbasetrans.h>
#include <gstopencvvideofilter.h>
G_BEGIN_DECLS
@ -67,14 +67,14 @@ typedef struct _GstCvDilateErodeClass GstCvDilateErodeClass;
struct _GstCvDilateErode
{
GstOpencvBaseTransform element;
GstOpencvVideoFilter element;
gint iterations;
};
struct _GstCvDilateErodeClass
{
GstOpencvBaseTransformClass parent_class;
GstOpencvVideoFilterClass parent_class;
};
GType gst_cv_dilate_erode_get_type (void);

View file

@ -63,10 +63,10 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("video/x-raw-gray, depth=(int)8, bpp=(int)8"));
GST_BOILERPLATE (GstCvEqualizeHist, gst_cv_equalize_hist,
GstOpencvBaseTransform, GST_TYPE_OPENCV_BASE_TRANSFORM);
GstOpencvVideoFilter, GST_TYPE_OPENCV_VIDEO_FILTER);
static GstFlowReturn gst_cv_equalize_hist_transform (
GstOpencvBaseTransform * filter, GstBuffer * buf, IplImage * img,
GstOpencvVideoFilter * filter, GstBuffer * buf, IplImage * img,
GstBuffer * outbuf, IplImage * outimg);
/* Clean up */
@ -99,10 +99,10 @@ static void
gst_cv_equalize_hist_class_init (GstCvEqualizeHistClass * klass)
{
GObjectClass *gobject_class;
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
gobject_class = (GObjectClass *) klass;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_cv_equalize_hist_finalize);
@ -117,7 +117,7 @@ gst_cv_equalize_hist_init (GstCvEqualizeHist * filter,
}
static GstFlowReturn
gst_cv_equalize_hist_transform (GstOpencvBaseTransform * base,
gst_cv_equalize_hist_transform (GstOpencvVideoFilter * base,
GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
cvEqualizeHist (img, outimg);

View file

@ -46,7 +46,7 @@
#include <gst/gst.h>
#include <cv.h>
#include <gstopencvbasetrans.h>
#include <gstopencvvideofilter.h>
G_BEGIN_DECLS
@ -67,12 +67,12 @@ typedef struct _GstCvEqualizeHistClass GstCvEqualizeHistClass;
struct _GstCvEqualizeHist
{
GstOpencvBaseTransform element;
GstOpencvVideoFilter element;
};
struct _GstCvEqualizeHistClass
{
GstOpencvBaseTransformClass parent_class;
GstOpencvVideoFilterClass parent_class;
};
GType gst_cv_equalize_hist_get_type (void);

View file

@ -55,9 +55,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_cv_erode_debug);
GST_BOILERPLATE (GstCvErode, gst_cv_erode, GstCvDilateErode,
GST_TYPE_CV_DILATE_ERODE);
static GstFlowReturn gst_cv_erode_transform_ip (GstOpencvBaseTransform *
static GstFlowReturn gst_cv_erode_transform_ip (GstOpencvVideoFilter *
filter, GstBuffer * buf, IplImage * img);
static GstFlowReturn gst_cv_erode_transform (GstOpencvBaseTransform * filter,
static GstFlowReturn gst_cv_erode_transform (GstOpencvVideoFilter * filter,
GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
/* GObject vmethod implementations */
@ -77,9 +77,9 @@ gst_cv_erode_base_init (gpointer gclass)
static void
gst_cv_erode_class_init (GstCvErodeClass * klass)
{
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@ -98,7 +98,7 @@ gst_cv_erode_init (GstCvErode * filter, GstCvErodeClass * gclass)
}
static GstFlowReturn
gst_cv_erode_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_erode_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);
@ -110,7 +110,7 @@ gst_cv_erode_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
}
static GstFlowReturn
gst_cv_erode_transform_ip (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_erode_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img)
{
GstCvDilateErode *filter = GST_CV_DILATE_ERODE (base);

View file

@ -79,8 +79,8 @@ enum
#define DEFAULT_APERTURE_SIZE 3
GST_BOILERPLATE (GstCvLaplace, gst_cv_laplace, GstOpencvBaseTransform,
GST_TYPE_OPENCV_BASE_TRANSFORM);
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);
@ -90,10 +90,10 @@ static void gst_cv_laplace_get_property (GObject * object, guint prop_id,
static GstCaps *gst_cv_laplace_transform_caps (GstBaseTransform * trans,
GstPadDirection dir, GstCaps * caps);
static GstFlowReturn gst_cv_laplace_transform (GstOpencvBaseTransform * filter,
static GstFlowReturn gst_cv_laplace_transform (GstOpencvVideoFilter * filter,
GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
static gboolean gst_cv_laplace_cv_set_caps (GstOpencvBaseTransform * trans,
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);
@ -134,13 +134,13 @@ gst_cv_laplace_class_init (GstCvLaplaceClass * klass)
{
GObjectClass *gobject_class;
GstBaseTransformClass *gstbasetransform_class;
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasetransform_class = (GstBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@ -168,7 +168,7 @@ gst_cv_laplace_init (GstCvLaplace * filter, GstCvLaplaceClass * gclass)
}
static gboolean
gst_cv_laplace_cv_set_caps (GstOpencvBaseTransform * trans, gint in_width,
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)
{
@ -273,7 +273,7 @@ gst_cv_laplace_get_property (GObject * object, guint prop_id,
}
static GstFlowReturn
gst_cv_laplace_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_laplace_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
GstCvLaplace *filter = GST_CV_LAPLACE (base);

View file

@ -46,7 +46,7 @@
#include <gst/gst.h>
#include <cv.h>
#include <gstopencvbasetrans.h>
#include <gstopencvvideofilter.h>
G_BEGIN_DECLS
@ -67,7 +67,7 @@ typedef struct _GstCvLaplaceClass GstCvLaplaceClass;
struct _GstCvLaplace
{
GstOpencvBaseTransform element;
GstOpencvVideoFilter element;
gint aperture_size;
@ -76,7 +76,7 @@ struct _GstCvLaplace
struct _GstCvLaplaceClass
{
GstOpencvBaseTransformClass parent_class;
GstOpencvVideoFilterClass parent_class;
};
GType gst_cv_laplace_get_type (void);

View file

@ -119,17 +119,17 @@ gst_cv_smooth_type_get_type (void)
#define DEFAULT_PARAM3 0.0
#define DEFAULT_PARAM4 0.0
GST_BOILERPLATE (GstCvSmooth, gst_cv_smooth, GstOpencvBaseTransform,
GST_TYPE_OPENCV_BASE_TRANSFORM);
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 (GstOpencvBaseTransform *
static GstFlowReturn gst_cv_smooth_transform_ip (GstOpencvVideoFilter *
filter, GstBuffer * buf, IplImage * img);
static GstFlowReturn gst_cv_smooth_transform (GstOpencvBaseTransform * filter,
static GstFlowReturn gst_cv_smooth_transform (GstOpencvVideoFilter * filter,
GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
/* Clean up */
@ -164,12 +164,12 @@ static void
gst_cv_smooth_class_init (GstCvSmoothClass * klass)
{
GObjectClass *gobject_class;
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@ -328,7 +328,7 @@ gst_cv_smooth_get_property (GObject * object, guint prop_id,
}
static GstFlowReturn
gst_cv_smooth_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_smooth_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
GstCvSmooth *filter = GST_CV_SMOOTH (base);
@ -340,7 +340,7 @@ gst_cv_smooth_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
}
static GstFlowReturn
gst_cv_smooth_transform_ip (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_smooth_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img)
{
GstCvSmooth *filter = GST_CV_SMOOTH (base);

View file

@ -46,7 +46,7 @@
#include <gst/gst.h>
#include <cv.h>
#include <gstopencvbasetrans.h>
#include <gstopencvvideofilter.h>
G_BEGIN_DECLS
@ -67,7 +67,7 @@ typedef struct _GstCvSmoothClass GstCvSmoothClass;
struct _GstCvSmooth
{
GstOpencvBaseTransform element;
GstOpencvVideoFilter element;
gint type;
@ -79,7 +79,7 @@ struct _GstCvSmooth
struct _GstCvSmoothClass
{
GstOpencvBaseTransformClass parent_class;
GstOpencvVideoFilterClass parent_class;
};
GType gst_cv_smooth_get_type (void);

View file

@ -83,8 +83,8 @@ enum
#define DEFAULT_Y_ORDER 0
#define DEFAULT_APERTURE_SIZE 3
GST_BOILERPLATE (GstCvSobel, gst_cv_sobel, GstOpencvBaseTransform,
GST_TYPE_OPENCV_BASE_TRANSFORM);
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);
@ -94,7 +94,7 @@ static void gst_cv_sobel_get_property (GObject * object, guint prop_id,
static GstCaps *gst_cv_sobel_transform_caps (GstBaseTransform * trans,
GstPadDirection dir, GstCaps * caps);
static GstFlowReturn gst_cv_sobel_transform (GstOpencvBaseTransform * filter,
static GstFlowReturn gst_cv_sobel_transform (GstOpencvVideoFilter * filter,
GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
/* Clean up */
@ -129,13 +129,13 @@ gst_cv_sobel_class_init (GstCvSobelClass * klass)
{
GObjectClass *gobject_class;
GstBaseTransformClass *gstbasetransform_class;
GstOpencvBaseTransformClass *gstopencvbasefilter_class;
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasetransform_class = (GstBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvBaseTransformClass *) klass;
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@ -260,7 +260,7 @@ gst_cv_sobel_get_property (GObject * object, guint prop_id,
}
static GstFlowReturn
gst_cv_sobel_transform (GstOpencvBaseTransform * base, GstBuffer * buf,
gst_cv_sobel_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
GstCvSobel *filter = GST_CV_SOBEL (base);

View file

@ -46,7 +46,7 @@
#include <gst/gst.h>
#include <cv.h>
#include <gstopencvbasetrans.h>
#include <gstopencvvideofilter.h>
G_BEGIN_DECLS
@ -67,7 +67,7 @@ typedef struct _GstCvSobelClass GstCvSobelClass;
struct _GstCvSobel
{
GstOpencvBaseTransform element;
GstOpencvVideoFilter element;
gint x_order;
gint y_order;
@ -76,7 +76,7 @@ struct _GstCvSobel
struct _GstCvSobelClass
{
GstOpencvBaseTransformClass parent_class;
GstOpencvVideoFilterClass parent_class;
};
GType gst_cv_sobel_get_type (void);

View file

@ -49,11 +49,11 @@
#include <gst/gst.h>
#include "gstopencvbasetrans.h"
#include "gstopencvvideofilter.h"
#include "gstopencvutils.h"
GST_DEBUG_CATEGORY_STATIC (gst_opencv_base_transform_debug);
#define GST_CAT_DEFAULT gst_opencv_base_transform_debug
GST_DEBUG_CATEGORY_STATIC (gst_opencv_video_filter_debug);
#define GST_CAT_DEFAULT gst_opencv_video_filter_debug
/* Filter signals and args */
enum
@ -69,47 +69,45 @@ enum
static GstElementClass *parent_class = NULL;
static void gst_opencv_base_transform_class_init (GstOpencvBaseTransformClass *
static void gst_opencv_video_filter_class_init (GstOpencvVideoFilterClass *
klass);
static void gst_opencv_base_transform_init (GstOpencvBaseTransform * trans,
GstOpencvBaseTransformClass * klass);
static void gst_opencv_base_transform_base_init (gpointer gclass);
static void gst_opencv_video_filter_init (GstOpencvVideoFilter * trans,
GstOpencvVideoFilterClass * klass);
static void gst_opencv_video_filter_base_init (gpointer gclass);
static gboolean gst_opencv_base_transform_set_caps (GstBaseTransform * trans,
static gboolean gst_opencv_video_filter_set_caps (GstBaseTransform * trans,
GstCaps * incaps, GstCaps * outcaps);
static GstFlowReturn gst_opencv_base_transform_transform_ip (GstBaseTransform *
static GstFlowReturn gst_opencv_video_filter_transform_ip (GstBaseTransform *
trans, GstBuffer * buf);
static GstFlowReturn gst_opencv_base_transform_transform (GstBaseTransform *
static GstFlowReturn gst_opencv_video_filter_transform (GstBaseTransform *
trans, GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_opencv_base_transform_get_unit_size (GstBaseTransform *
trans, GstCaps * caps, guint * size);
static void gst_opencv_base_transform_set_property (GObject * object,
static void gst_opencv_video_filter_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_opencv_base_transform_get_property (GObject * object,
static void gst_opencv_video_filter_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
GType
gst_opencv_base_transform_get_type (void)
gst_opencv_video_filter_get_type (void)
{
static volatile gsize opencv_base_transform_type = 0;
if (g_once_init_enter (&opencv_base_transform_type)) {
GType _type;
static const GTypeInfo opencv_base_transform_info = {
sizeof (GstOpencvBaseTransformClass),
(GBaseInitFunc) gst_opencv_base_transform_base_init,
sizeof (GstOpencvVideoFilterClass),
(GBaseInitFunc) gst_opencv_video_filter_base_init,
NULL,
(GClassInitFunc) gst_opencv_base_transform_class_init,
(GClassInitFunc) gst_opencv_video_filter_class_init,
NULL,
NULL,
sizeof (GstOpencvBaseTransform),
sizeof (GstOpencvVideoFilter),
0,
(GInstanceInitFunc) gst_opencv_base_transform_init,
(GInstanceInitFunc) gst_opencv_video_filter_init,
};
_type = g_type_register_static (GST_TYPE_BASE_TRANSFORM,
"GstOpencvBaseTransform", &opencv_base_transform_info,
_type = g_type_register_static (GST_TYPE_VIDEO_FILTER,
"GstOpencvVideoFilter", &opencv_base_transform_info,
G_TYPE_FLAG_ABSTRACT);
g_once_init_leave (&opencv_base_transform_type, _type);
}
@ -118,9 +116,9 @@ gst_opencv_base_transform_get_type (void)
/* Clean up */
static void
gst_opencv_base_transform_finalize (GObject * obj)
gst_opencv_video_filter_finalize (GObject * obj)
{
GstOpencvBaseTransform *transform = GST_OPENCV_BASE_TRANSFORM (obj);
GstOpencvVideoFilter *transform = GST_OPENCV_VIDEO_FILTER (obj);
if (transform->cvImage)
cvReleaseImage (&transform->cvImage);
@ -130,12 +128,12 @@ gst_opencv_base_transform_finalize (GObject * obj)
/* GObject vmethod implementations */
static void
gst_opencv_base_transform_base_init (gpointer gclass)
gst_opencv_video_filter_base_init (gpointer gclass)
{
}
static void
gst_opencv_base_transform_class_init (GstOpencvBaseTransformClass * klass)
gst_opencv_video_filter_class_init (GstOpencvVideoFilterClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -146,35 +144,34 @@ gst_opencv_base_transform_class_init (GstOpencvBaseTransformClass * klass)
basetrans_class = (GstBaseTransformClass *) klass;
parent_class = g_type_class_peek_parent (klass);
GST_DEBUG_CATEGORY_INIT (gst_opencv_base_transform_debug,
GST_DEBUG_CATEGORY_INIT (gst_opencv_video_filter_debug,
"opencvbasetransform", 0, "opencvbasetransform element");
gobject_class->finalize =
GST_DEBUG_FUNCPTR (gst_opencv_base_transform_finalize);
gobject_class->set_property = gst_opencv_base_transform_set_property;
gobject_class->get_property = gst_opencv_base_transform_get_property;
GST_DEBUG_FUNCPTR (gst_opencv_video_filter_finalize);
gobject_class->set_property = gst_opencv_video_filter_set_property;
gobject_class->get_property = gst_opencv_video_filter_get_property;
basetrans_class->transform = gst_opencv_base_transform_transform;
basetrans_class->transform_ip = gst_opencv_base_transform_transform_ip;
basetrans_class->set_caps = gst_opencv_base_transform_set_caps;
basetrans_class->get_unit_size = gst_opencv_base_transform_get_unit_size;
basetrans_class->transform = gst_opencv_video_filter_transform;
basetrans_class->transform_ip = gst_opencv_video_filter_transform_ip;
basetrans_class->set_caps = gst_opencv_video_filter_set_caps;
}
static void
gst_opencv_base_transform_init (GstOpencvBaseTransform * transform,
GstOpencvBaseTransformClass * bclass)
gst_opencv_video_filter_init (GstOpencvVideoFilter * transform,
GstOpencvVideoFilterClass * bclass)
{
}
static GstFlowReturn
gst_opencv_base_transform_transform (GstBaseTransform * trans,
gst_opencv_video_filter_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer * outbuf)
{
GstOpencvBaseTransform *transform;
GstOpencvBaseTransformClass *fclass;
GstOpencvVideoFilter *transform;
GstOpencvVideoFilterClass *fclass;
transform = GST_OPENCV_BASE_TRANSFORM (trans);
fclass = GST_OPENCV_BASE_TRANSFORM_GET_CLASS (transform);
transform = GST_OPENCV_VIDEO_FILTER (trans);
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
g_return_val_if_fail (fclass->cv_trans_func != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR);
@ -187,34 +184,35 @@ gst_opencv_base_transform_transform (GstBaseTransform * trans,
}
static GstFlowReturn
gst_opencv_base_transform_transform_ip (GstBaseTransform * trans,
gst_opencv_video_filter_transform_ip (GstBaseTransform * trans,
GstBuffer * buffer)
{
GstOpencvBaseTransform *transform;
GstOpencvBaseTransformClass *fclass;
GstOpencvVideoFilter *transform;
GstOpencvVideoFilterClass *fclass;
transform = GST_OPENCV_BASE_TRANSFORM (trans);
fclass = GST_OPENCV_BASE_TRANSFORM_GET_CLASS (transform);
transform = GST_OPENCV_VIDEO_FILTER (trans);
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
g_return_val_if_fail (fclass->cv_trans_ip_func != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR);
/* TODO this is not always needed and should be solved at BaseTransform
* level */
buffer = gst_buffer_make_writable (buffer);
transform->cvImage->imageData = (char *) GST_BUFFER_DATA (buffer);
/* FIXME how to release buffer? */
return fclass->cv_trans_ip_func (transform, buffer, transform->cvImage);
}
static gboolean
gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
gst_opencv_video_filter_set_caps (GstBaseTransform * trans, GstCaps * incaps,
GstCaps * outcaps)
{
GstOpencvBaseTransform *transform = GST_OPENCV_BASE_TRANSFORM (trans);
GstOpencvBaseTransformClass *klass =
GST_OPENCV_BASE_TRANSFORM_GET_CLASS (transform);
GstOpencvVideoFilter *transform = GST_OPENCV_VIDEO_FILTER (trans);
GstOpencvVideoFilterClass *klass =
GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
gint in_width, in_height;
gint in_depth, in_channels;
gint out_width, out_height;
@ -239,7 +237,7 @@ gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
}
if (klass->cv_set_caps) {
if (!klass->cv_set_caps(transform, in_width, in_height, in_depth,
if (!klass->cv_set_caps (transform, in_width, in_height, in_depth,
in_channels, out_width, out_height, out_depth, out_channels))
return FALSE;
}
@ -262,27 +260,8 @@ gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
return TRUE;
}
static gboolean
gst_opencv_base_transform_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, guint * size)
{
gint width, height;
gint bpp;
GstStructure *structure;
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (structure, "width", &width) ||
!gst_structure_get_int (structure, "height", &height) ||
!gst_structure_get_int (structure, "bpp", &bpp)) {
return FALSE;
}
*size = width * height * bpp / 8;
return TRUE;
}
static void
gst_opencv_base_transform_set_property (GObject * object, guint prop_id,
gst_opencv_video_filter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
@ -293,7 +272,7 @@ gst_opencv_base_transform_set_property (GObject * object, guint prop_id,
}
static void
gst_opencv_base_transform_get_property (GObject * object, guint prop_id,
gst_opencv_video_filter_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
@ -304,7 +283,7 @@ gst_opencv_base_transform_get_property (GObject * object, guint prop_id,
}
void
gst_opencv_base_transform_set_in_place (GstOpencvBaseTransform * transform,
gst_opencv_video_filter_set_in_place (GstOpencvVideoFilter * transform,
gboolean ip)
{
transform->in_place = ip;

View file

@ -41,44 +41,45 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_OPENCV_BASE_TRANSFORM_H__
#define __GST_OPENCV_BASE_TRANSFORM_H__
#ifndef __GST_OPENCV_VIDEO_FILTER_H__
#define __GST_OPENCV_VIDEO_FILTER_H__
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include <gst/video/gstvideofilter.h>
#include <cv.h>
G_BEGIN_DECLS
/* #defines don't like whitespacey bits */
#define GST_TYPE_OPENCV_BASE_TRANSFORM \
(gst_opencv_base_transform_get_type())
#define GST_OPENCV_BASE_TRANSFORM(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENCV_BASE_TRANSFORM,GstOpencvBaseTransform))
#define GST_OPENCV_BASE_TRANSFORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENCV_BASE_TRANSFORM,GstOpencvBaseTransformClass))
#define GST_IS_OPENCV_BASE_TRANSFORM(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENCV_BASE_TRANSFORM))
#define GST_IS_OPENCV_BASE_TRANSFORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENCV_BASE_TRANSFORM))
#define GST_OPENCV_BASE_TRANSFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OPENCV_BASE_TRANSFORM,GstOpencvBaseTransformClass))
#define GST_TYPE_OPENCV_VIDEO_FILTER \
(gst_opencv_video_filter_get_type())
#define GST_OPENCV_VIDEO_FILTER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENCV_VIDEO_FILTER,GstOpencvVideoFilter))
#define GST_OPENCV_VIDEO_FILTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENCV_VIDEO_FILTER,GstOpencvVideoFilterClass))
#define GST_IS_OPENCV_VIDEO_FILTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENCV_VIDEO_FILTER))
#define GST_IS_OPENCV_VIDEO_FILTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENCV_VIDEO_FILTER))
#define GST_OPENCV_VIDEO_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OPENCV_VIDEO_FILTER,GstOpencvVideoFilterClass))
#define GST_OPENCV_VIDEO_FILTER_CAST(obj) ((GstOpencvVideoFilter *) (obj))
typedef struct _GstOpencvBaseTransform GstOpencvBaseTransform;
typedef struct _GstOpencvBaseTransformClass GstOpencvBaseTransformClass;
typedef struct _GstOpencvVideoFilter GstOpencvVideoFilter;
typedef struct _GstOpencvVideoFilterClass GstOpencvVideoFilterClass;
typedef GstFlowReturn (*GstOpencvBaseTransformTransformIPFunc)
(GstOpencvBaseTransform * transform, GstBuffer * buffer, IplImage * img);
typedef GstFlowReturn (*GstOpencvBaseTransformTransformFunc)
(GstOpencvBaseTransform * transform, GstBuffer * buffer, IplImage * img,
typedef GstFlowReturn (*GstOpencvVideoFilterTransformIPFunc)
(GstOpencvVideoFilter * transform, GstBuffer * buffer, IplImage * img);
typedef GstFlowReturn (*GstOpencvVideoFilterTransformFunc)
(GstOpencvVideoFilter * transform, GstBuffer * buffer, IplImage * img,
GstBuffer * outbuf, IplImage * outimg);
typedef gboolean (*GstOpencvBaseTransformSetCaps)
(GstOpencvBaseTransform * transform, gint in_width, gint in_height,
typedef gboolean (*GstOpencvVideoFilterSetCaps)
(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);
struct _GstOpencvBaseTransform
struct _GstOpencvVideoFilter
{
GstBaseTransform trans;
GstVideoFilter trans;
gboolean in_place;
@ -86,20 +87,20 @@ struct _GstOpencvBaseTransform
IplImage *out_cvImage;
};
struct _GstOpencvBaseTransformClass
struct _GstOpencvVideoFilterClass
{
GstBaseTransformClass parent_class;
GstVideoFilterClass parent_class;
GstOpencvBaseTransformTransformFunc cv_trans_func;
GstOpencvBaseTransformTransformIPFunc cv_trans_ip_func;
GstOpencvVideoFilterTransformFunc cv_trans_func;
GstOpencvVideoFilterTransformIPFunc cv_trans_ip_func;
GstOpencvBaseTransformSetCaps cv_set_caps;
GstOpencvVideoFilterSetCaps cv_set_caps;
};
GType gst_opencv_base_transform_get_type (void);
GType gst_opencv_video_filter_get_type (void);
void gst_opencv_base_transform_set_in_place (GstOpencvBaseTransform * transform,
void gst_opencv_video_filter_set_in_place (GstOpencvVideoFilter * transform,
gboolean ip);
G_END_DECLS
#endif /* __GST_OPENCV_BASE_TRANSFORM_H__ */
#endif /* __GST_OPENCV_VIDEO_FILTER_H__ */