mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Bring code in to line with general Gstreamer standards
This commit is contained in:
parent
0961dbefd4
commit
babe97ca50
11 changed files with 390 additions and 386 deletions
|
@ -90,21 +90,16 @@ 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 ("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_STATIC_CAPS ("video/x-raw-rgb")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (Gstedgedetect, gst_edgedetect, GstElement,
|
||||
GST_TYPE_ELEMENT);
|
||||
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);
|
||||
|
@ -120,8 +115,7 @@ gst_edgedetect_finalize (GObject * obj)
|
|||
{
|
||||
Gstedgedetect *filter = GST_EDGEDETECT (obj);
|
||||
|
||||
if (filter->cvImage != NULL)
|
||||
{
|
||||
if (filter->cvImage != NULL) {
|
||||
cvReleaseImage (&filter->cvImage);
|
||||
cvReleaseImage (&filter->cvCEdge);
|
||||
cvReleaseImage (&filter->cvGray);
|
||||
|
@ -137,11 +131,11 @@ 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_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));
|
||||
|
@ -165,17 +159,21 @@ gst_edgedetect_class_init (GstedgedetectClass * klass)
|
|||
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",
|
||||
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_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_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));
|
||||
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
|
||||
|
@ -184,20 +182,19 @@ gst_edgedetect_class_init (GstedgedetectClass * klass)
|
|||
* initialize instance structure
|
||||
*/
|
||||
static void
|
||||
gst_edgedetect_init (Gstedgedetect * filter,
|
||||
GstedgedetectClass * gclass)
|
||||
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_DEBUG_FUNCPTR (gst_edgedetect_set_caps));
|
||||
gst_pad_set_getcaps_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_pad_set_chain_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_edgedetect_chain));
|
||||
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_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
|
||||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
||||
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
||||
|
@ -273,10 +270,10 @@ gst_edgedetect_set_caps (GstPad * pad, GstCaps * caps)
|
|||
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);
|
||||
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);
|
||||
|
@ -296,18 +293,20 @@ gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
|
|||
|
||||
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);
|
||||
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);
|
||||
cvZero (filter->cvCEdge);
|
||||
if (filter->mask) {
|
||||
cvCopy (filter->cvImage, filter->cvCEdge, filter->cvEdge);
|
||||
} else {
|
||||
cvCvtColor(filter->cvEdge, filter->cvCEdge, CV_GRAY2RGB);
|
||||
cvCvtColor (filter->cvEdge, filter->cvCEdge, CV_GRAY2RGB);
|
||||
}
|
||||
gst_buffer_set_data(buf, filter->cvCEdge->imageData, filter->cvCEdge->imageSize);
|
||||
gst_buffer_set_data (buf, filter->cvCEdge->imageData,
|
||||
filter->cvCEdge->imageSize);
|
||||
|
||||
return gst_pad_push (filter->srcpad, buf);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <cv.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define GST_TYPE_EDGEDETECT \
|
||||
(gst_edgedetect_get_type())
|
||||
|
@ -62,8 +61,7 @@ G_BEGIN_DECLS
|
|||
(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 _Gstedgedetect Gstedgedetect;
|
||||
typedef struct _GstedgedetectClass GstedgedetectClass;
|
||||
|
||||
struct _Gstedgedetect
|
||||
|
@ -79,7 +77,7 @@ struct _Gstedgedetect
|
|||
IplImage *cvEdge, *cvGray, *cvImage, *cvCEdge;
|
||||
};
|
||||
|
||||
struct _GstedgedetectClass
|
||||
struct _GstedgedetectClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
@ -89,5 +87,4 @@ GType gst_edgedetect_get_type (void);
|
|||
gboolean gst_edgedetect_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_EDGEDETECT_H__ */
|
||||
|
|
|
@ -87,21 +87,16 @@ 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 ("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_STATIC_CAPS ("video/x-raw-rgb")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (Gstfaceblur, gst_faceblur, GstElement,
|
||||
GST_TYPE_ELEMENT);
|
||||
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);
|
||||
|
@ -117,10 +112,9 @@ static void gst_faceblur_load_profile (Gstfaceblur * filter);
|
|||
static void
|
||||
gst_faceblur_finalize (GObject * obj)
|
||||
{
|
||||
Gstfaceblur *filter = GST_FACEBLUR(obj);
|
||||
Gstfaceblur *filter = GST_FACEBLUR (obj);
|
||||
|
||||
if (filter->cvImage)
|
||||
{
|
||||
if (filter->cvImage) {
|
||||
cvReleaseImage (&filter->cvImage);
|
||||
cvReleaseImage (&filter->cvGray);
|
||||
}
|
||||
|
@ -135,11 +129,11 @@ 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_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));
|
||||
|
@ -163,7 +157,8 @@ gst_faceblur_class_init (GstfaceblurClass * klass)
|
|||
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",
|
||||
g_param_spec_string ("profile", "Profile",
|
||||
"Location of Haar cascade file to use for face blurion",
|
||||
DEFAULT_PROFILE, G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
|
@ -173,25 +168,24 @@ gst_faceblur_class_init (GstfaceblurClass * klass)
|
|||
* initialize instance structure
|
||||
*/
|
||||
static void
|
||||
gst_faceblur_init (Gstfaceblur * filter,
|
||||
GstfaceblurClass * gclass)
|
||||
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_DEBUG_FUNCPTR (gst_faceblur_set_caps));
|
||||
gst_pad_set_getcaps_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_pad_set_chain_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_faceblur_chain));
|
||||
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_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 = DEFAULT_PROFILE;
|
||||
gst_faceblur_load_profile(filter);
|
||||
gst_faceblur_load_profile (filter);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -203,7 +197,7 @@ gst_faceblur_set_property (GObject * object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_PROFILE:
|
||||
filter->profile = g_value_dup_string (value);
|
||||
gst_faceblur_load_profile(filter);
|
||||
gst_faceblur_load_profile (filter);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -243,9 +237,9 @@ gst_faceblur_set_caps (GstPad * pad, GstCaps * caps)
|
|||
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);
|
||||
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);
|
||||
|
@ -267,30 +261,36 @@ gst_faceblur_chain (GstPad * pad, GstBuffer * buf)
|
|||
|
||||
filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
|
||||
|
||||
cvCvtColor(filter->cvImage, filter->cvGray, CV_RGB2GRAY);
|
||||
cvClearMemStorage(filter->cvStorage);
|
||||
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));
|
||||
|
||||
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);
|
||||
faces =
|
||||
cvHaarDetectObjects (filter->cvGray, filter->cvCascade,
|
||||
filter->cvStorage, 1.1, 2, 0, cvSize (30, 30));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gst_buffer_set_data(buf, filter->cvImage->imageData, filter->cvImage->imageSize);
|
||||
gst_buffer_set_data (buf, filter->cvImage->imageData,
|
||||
filter->cvImage->imageSize);
|
||||
|
||||
return gst_pad_push (filter->srcpad, buf);
|
||||
}
|
||||
|
||||
|
||||
static void gst_faceblur_load_profile(Gstfaceblur * filter) {
|
||||
filter->cvCascade = (CvHaarClassifierCascade*)cvLoad(filter->profile, 0, 0, 0 );
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <cv.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define GST_TYPE_FACEBLUR \
|
||||
(gst_faceblur_get_type())
|
||||
|
@ -62,8 +61,7 @@ G_BEGIN_DECLS
|
|||
(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 _Gstfaceblur Gstfaceblur;
|
||||
typedef struct _GstfaceblurClass GstfaceblurClass;
|
||||
|
||||
struct _Gstfaceblur
|
||||
|
@ -81,7 +79,7 @@ struct _Gstfaceblur
|
|||
CvMemStorage *cvStorage;
|
||||
};
|
||||
|
||||
struct _GstfaceblurClass
|
||||
struct _GstfaceblurClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
@ -91,5 +89,4 @@ GType gst_faceblur_get_type (void);
|
|||
gboolean gst_faceblur_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_FACEBLUR_H__ */
|
||||
|
|
|
@ -88,21 +88,16 @@ 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 ("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_STATIC_CAPS ("video/x-raw-rgb")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (Gstfacedetect, gst_facedetect, GstElement,
|
||||
GST_TYPE_ELEMENT);
|
||||
GST_BOILERPLATE (Gstfacedetect, gst_facedetect, GstElement, GST_TYPE_ELEMENT);
|
||||
|
||||
static void gst_facedetect_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
|
@ -118,10 +113,9 @@ static void gst_facedetect_load_profile (Gstfacedetect * filter);
|
|||
static void
|
||||
gst_facedetect_finalize (GObject * obj)
|
||||
{
|
||||
Gstfacedetect *filter = GST_FACEDETECT(obj);
|
||||
Gstfacedetect *filter = GST_FACEDETECT (obj);
|
||||
|
||||
if (filter->cvImage)
|
||||
{
|
||||
if (filter->cvImage) {
|
||||
cvReleaseImage (&filter->cvImage);
|
||||
cvReleaseImage (&filter->cvGray);
|
||||
}
|
||||
|
@ -136,11 +130,11 @@ 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_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));
|
||||
|
@ -164,10 +158,12 @@ gst_facedetect_class_init (GstfacedetectClass * klass)
|
|||
gobject_class->get_property = gst_facedetect_get_property;
|
||||
|
||||
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",
|
||||
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",
|
||||
g_param_spec_string ("profile", "Profile",
|
||||
"Location of Haar cascade file to use for face detection",
|
||||
DEFAULT_PROFILE, G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
|
@ -177,26 +173,25 @@ gst_facedetect_class_init (GstfacedetectClass * klass)
|
|||
* initialize instance structure
|
||||
*/
|
||||
static void
|
||||
gst_facedetect_init (Gstfacedetect * filter,
|
||||
GstfacedetectClass * gclass)
|
||||
gst_facedetect_init (Gstfacedetect * filter, GstfacedetectClass * gclass)
|
||||
{
|
||||
filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
|
||||
gst_pad_set_setcaps_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_facedetect_set_caps));
|
||||
GST_DEBUG_FUNCPTR (gst_facedetect_set_caps));
|
||||
gst_pad_set_getcaps_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_pad_set_chain_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_facedetect_chain));
|
||||
GST_DEBUG_FUNCPTR (gst_facedetect_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_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 = DEFAULT_PROFILE;
|
||||
filter->display = TRUE;
|
||||
gst_facedetect_load_profile(filter);
|
||||
gst_facedetect_load_profile (filter);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -208,7 +203,7 @@ gst_facedetect_set_property (GObject * object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_PROFILE:
|
||||
filter->profile = g_value_dup_string (value);
|
||||
gst_facedetect_load_profile(filter);
|
||||
gst_facedetect_load_profile (filter);
|
||||
break;
|
||||
case PROP_DISPLAY:
|
||||
filter->display = g_value_get_boolean (value);
|
||||
|
@ -254,9 +249,9 @@ gst_facedetect_set_caps (GstPad * pad, GstCaps * caps)
|
|||
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);
|
||||
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);
|
||||
|
@ -278,20 +273,22 @@ gst_facedetect_chain (GstPad * pad, GstBuffer * buf)
|
|||
|
||||
filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
|
||||
|
||||
cvCvtColor(filter->cvImage, filter->cvGray, CV_RGB2GRAY);
|
||||
cvClearMemStorage(filter->cvStorage);
|
||||
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));
|
||||
|
||||
for (i = 0; i < (faces ? faces->total : 0); i++) {
|
||||
CvRect* r = (CvRect *) cvGetSeqElem(faces, i);
|
||||
faces =
|
||||
cvHaarDetectObjects (filter->cvGray, filter->cvCascade,
|
||||
filter->cvStorage, 1.1, 2, 0, cvSize (30, 30));
|
||||
|
||||
for (i = 0; i < (faces ? faces->total : 0); i++) {
|
||||
CvRect *r = (CvRect *) cvGetSeqElem (faces, i);
|
||||
|
||||
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);
|
||||
"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);
|
||||
gst_element_post_message (GST_ELEMENT (filter), m);
|
||||
|
@ -299,24 +296,29 @@ gst_facedetect_chain (GstPad * pad, GstBuffer * buf)
|
|||
if (filter->display) {
|
||||
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(filter->cvImage, center, radius, CV_RGB(255, 32, 32), 3, 8, 0);
|
||||
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 (filter->cvImage, center, radius, CV_RGB (255, 32, 32), 3, 8,
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gst_buffer_set_data(buf, filter->cvImage->imageData, filter->cvImage->imageSize);
|
||||
gst_buffer_set_data (buf, filter->cvImage->imageData,
|
||||
filter->cvImage->imageSize);
|
||||
|
||||
return gst_pad_push (filter->srcpad, buf);
|
||||
}
|
||||
|
||||
|
||||
static void gst_facedetect_load_profile(Gstfacedetect * filter) {
|
||||
filter->cvCascade = (CvHaarClassifierCascade*)cvLoad(filter->profile, 0, 0, 0 );
|
||||
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);
|
||||
}
|
||||
|
@ -332,7 +334,8 @@ 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");
|
||||
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);
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <cv.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define GST_TYPE_FACEDETECT \
|
||||
(gst_facedetect_get_type())
|
||||
|
@ -62,8 +61,7 @@ G_BEGIN_DECLS
|
|||
(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 _Gstfacedetect Gstfacedetect;
|
||||
typedef struct _GstfacedetectClass GstfacedetectClass;
|
||||
|
||||
struct _Gstfacedetect
|
||||
|
@ -81,7 +79,7 @@ struct _Gstfacedetect
|
|||
CvMemStorage *cvStorage;
|
||||
};
|
||||
|
||||
struct _GstfacedetectClass
|
||||
struct _GstfacedetectClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
@ -91,5 +89,4 @@ GType gst_facedetect_get_type (void);
|
|||
gboolean gst_facedetect_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_FACEDETECT_H__ */
|
||||
|
|
|
@ -36,18 +36,18 @@ plugin_init (GstPlugin * plugin)
|
|||
if (!gst_edgedetect_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_faceblur_plugin_init(plugin))
|
||||
if (!gst_faceblur_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_facedetect_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
|
||||
if (!gst_pyramidsegment_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_templatematch_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,12 +114,11 @@ static GstFlowReturn gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf);
|
|||
|
||||
/* Clean up */
|
||||
static void
|
||||
gst_pyramidsegment_finalize (GObject * obj)
|
||||
gst_pyramidsegment_finalize (GObject * obj)
|
||||
{
|
||||
Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT(obj);
|
||||
Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT (obj);
|
||||
|
||||
if (filter->cvImage != NULL)
|
||||
{
|
||||
if (filter->cvImage != NULL) {
|
||||
cvReleaseImage (&filter->cvImage);
|
||||
cvReleaseImage (&filter->cvSegmentedImage);
|
||||
}
|
||||
|
@ -133,11 +132,11 @@ 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_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));
|
||||
|
@ -165,16 +164,19 @@ gst_pyramidsegment_class_init (GstpyramidsegmentClass * klass)
|
|||
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_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_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));
|
||||
g_param_spec_int ("level", "Level",
|
||||
"Maximum level of the pyramid segmentation", 0, 4, 4,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
/* initialize the new element
|
||||
|
@ -188,20 +190,21 @@ gst_pyramidsegment_init (Gstpyramidsegment * filter,
|
|||
{
|
||||
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_DEBUG_FUNCPTR (gst_pyramidsegment_set_caps));
|
||||
gst_pad_set_getcaps_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
|
||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
||||
gst_pad_set_chain_function (filter->sinkpad,
|
||||
GST_DEBUG_FUNCPTR(gst_pyramidsegment_chain));
|
||||
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_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->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;
|
||||
|
@ -274,8 +277,8 @@ gst_pyramidsegment_set_caps (GstPad * pad, GstCaps * caps)
|
|||
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->cvImage = cvCreateImage (cvSize (width, height), IPL_DEPTH_8U, 3);
|
||||
|
||||
otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
|
||||
gst_object_unref (filter);
|
||||
|
@ -294,11 +297,13 @@ gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf)
|
|||
filter = GST_PYRAMIDSEGMENT (GST_OBJECT_PARENT (pad));
|
||||
|
||||
filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
|
||||
filter->cvSegmentedImage = cvCloneImage(filter->cvImage);
|
||||
filter->cvSegmentedImage = cvCloneImage (filter->cvImage);
|
||||
|
||||
cvPyrSegmentation(filter->cvImage, filter->cvSegmentedImage, filter->storage, &(filter->comp), filter->level, filter->threshold1, filter->threshold2);
|
||||
cvPyrSegmentation (filter->cvImage, filter->cvSegmentedImage, filter->storage,
|
||||
&(filter->comp), filter->level, filter->threshold1, filter->threshold2);
|
||||
|
||||
gst_buffer_set_data(buf, filter->cvSegmentedImage->imageData, filter->cvSegmentedImage->imageSize);
|
||||
gst_buffer_set_data (buf, filter->cvSegmentedImage->imageData,
|
||||
filter->cvSegmentedImage->imageSize);
|
||||
|
||||
return gst_pad_push (filter->srcpad, buf);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <cv.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define GST_TYPE_PYRAMIDSEGMENT \
|
||||
(gst_pyramidsegment_get_type())
|
||||
|
@ -62,8 +61,7 @@ G_BEGIN_DECLS
|
|||
(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 _Gstpyramidsegment Gstpyramidsegment;
|
||||
typedef struct _GstpyramidsegmentClass GstpyramidsegmentClass;
|
||||
|
||||
struct _Gstpyramidsegment
|
||||
|
@ -81,11 +79,11 @@ struct _Gstpyramidsegment
|
|||
CvSeq *comp;
|
||||
|
||||
double threshold1, threshold2;
|
||||
|
||||
|
||||
int level;
|
||||
};
|
||||
|
||||
struct _GstpyramidsegmentClass
|
||||
struct _GstpyramidsegmentClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
@ -95,5 +93,4 @@ GType gst_pyramidsegment_get_type (void);
|
|||
gboolean gst_pyramidsegment_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_PYRAMIDSEGMENT_H__ */
|
||||
|
|
|
@ -73,94 +73,92 @@ GST_DEBUG_CATEGORY_STATIC (gst_templatematch_debug);
|
|||
/* Filter signals and args */
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_METHOD,
|
||||
PROP_TEMPLATE,
|
||||
PROP_DISPLAY,
|
||||
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"
|
||||
)
|
||||
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_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (GstTemplateMatch, gst_templatematch, GstElement,
|
||||
GST_TYPE_ELEMENT);
|
||||
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);
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_templatematch_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
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);
|
||||
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);
|
||||
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_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));
|
||||
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;
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
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;
|
||||
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));
|
||||
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
|
||||
|
@ -170,87 +168,93 @@ gst_templatematch_class_init (GstTemplateMatchClass * klass)
|
|||
*/
|
||||
static void
|
||||
gst_templatematch_init (GstTemplateMatch * filter,
|
||||
GstTemplateMatchClass * gclass)
|
||||
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->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));
|
||||
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);
|
||||
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)
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
|
||||
GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
|
||||
|
||||
switch (prop_id) {
|
||||
switch (prop_id) {
|
||||
case PROP_METHOD:
|
||||
switch (g_value_get_int (value)) {
|
||||
switch (g_value_get_int (value)) {
|
||||
case 0:
|
||||
filter->method = CV_TM_SQDIFF; break;
|
||||
filter->method = CV_TM_SQDIFF;
|
||||
break;
|
||||
case 1:
|
||||
filter->method = CV_TM_SQDIFF_NORMED; break;
|
||||
filter->method = CV_TM_SQDIFF_NORMED;
|
||||
break;
|
||||
case 2:
|
||||
filter->method = CV_TM_CCORR; break;
|
||||
filter->method = CV_TM_CCORR;
|
||||
break;
|
||||
case 3:
|
||||
filter->method = CV_TM_CCORR_NORMED; break;
|
||||
filter->method = CV_TM_CCORR_NORMED;
|
||||
break;
|
||||
case 4:
|
||||
filter->method = CV_TM_CCOEFF; break;
|
||||
filter->method = CV_TM_CCOEFF;
|
||||
break;
|
||||
case 5:
|
||||
filter->method = CV_TM_CCOEFF_NORMED; break;
|
||||
}
|
||||
break;
|
||||
filter->method = CV_TM_CCOEFF_NORMED;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PROP_TEMPLATE:
|
||||
filter->template = g_value_get_string (value);
|
||||
gst_templatematch_load_template(filter);
|
||||
break;
|
||||
filter->template = g_value_get_string (value);
|
||||
gst_templatematch_load_template (filter);
|
||||
break;
|
||||
case PROP_DISPLAY:
|
||||
filter->display = g_value_get_boolean (value);
|
||||
break;
|
||||
filter->display = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
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)
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
|
||||
GstTemplateMatch *filter = GST_TEMPLATEMATCH (object);
|
||||
|
||||
switch (prop_id) {
|
||||
switch (prop_id) {
|
||||
case PROP_METHOD:
|
||||
g_value_set_int(value, filter->method);
|
||||
break;
|
||||
g_value_set_int (value, filter->method);
|
||||
break;
|
||||
case PROP_TEMPLATE:
|
||||
g_value_set_string (value, filter->template);
|
||||
break;
|
||||
g_value_set_string (value, filter->template);
|
||||
break;
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_boolean (value, filter->display);
|
||||
break;
|
||||
g_value_set_boolean (value, filter->display);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* GstElement vmethod implementations */
|
||||
|
@ -259,38 +263,40 @@ gst_templatematch_get_property (GObject * object, guint prop_id,
|
|||
static gboolean
|
||||
gst_templatematch_set_caps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
GstTemplateMatch *filter;
|
||||
GstPad *otherpad;
|
||||
gint width, height;
|
||||
GstStructure *structure;
|
||||
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 = 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);
|
||||
filter->cvImage =
|
||||
cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, 3);
|
||||
|
||||
otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
|
||||
gst_object_unref (filter);
|
||||
otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
|
||||
gst_object_unref (filter);
|
||||
|
||||
return gst_pad_set_caps (otherpad, caps);
|
||||
return gst_pad_set_caps (otherpad, caps);
|
||||
}
|
||||
|
||||
static void gst_templatematch_finalize (GObject * object)
|
||||
static void
|
||||
gst_templatematch_finalize (GObject * object)
|
||||
{
|
||||
GstTemplateMatch *filter;
|
||||
filter = GST_TEMPLATEMATCH (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);
|
||||
}
|
||||
if (filter->cvImage) {
|
||||
cvReleaseImageHeader (&filter->cvImage);
|
||||
}
|
||||
if (filter->cvDistImage) {
|
||||
cvReleaseImage (&filter->cvDistImage);
|
||||
}
|
||||
if (filter->cvTemplateImage) {
|
||||
cvReleaseImage (&filter->cvTemplateImage);
|
||||
}
|
||||
}
|
||||
|
||||
/* chain function
|
||||
|
@ -299,88 +305,94 @@ static void gst_templatematch_finalize (GObject * object)
|
|||
static GstFlowReturn
|
||||
gst_templatematch_chain (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
GstTemplateMatch *filter;
|
||||
CvPoint best_pos;
|
||||
double best_res;
|
||||
int i;
|
||||
GstTemplateMatch *filter;
|
||||
CvPoint best_pos;
|
||||
double best_res;
|
||||
int i;
|
||||
|
||||
filter = GST_TEMPLATEMATCH (GST_OBJECT_PARENT (pad));
|
||||
buf = gst_buffer_make_writable(buf);
|
||||
if ((!filter) || (!buf) || filter->template == NULL) {
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
filter->cvImage->imageData = (char *) GST_BUFFER_DATA (buf);
|
||||
filter = GST_TEMPLATEMATCH (GST_OBJECT_PARENT (pad));
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
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) {
|
||||
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.");
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (filter->cvTemplateImage) {
|
||||
gst_templatematch_match (filter->cvImage, filter->cvTemplateImage,
|
||||
filter->cvDistImage, &best_res, &best_pos, filter->method);
|
||||
|
||||
GstMessage *m = gst_message_new_element (GST_OBJECT (filter), s);
|
||||
gst_element_post_message (GST_ELEMENT (filter), m);
|
||||
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);
|
||||
|
||||
if (filter->display) {
|
||||
CvPoint corner = best_pos;
|
||||
corner.x += filter->cvTemplateImage->width;
|
||||
corner.y += filter->cvTemplateImage->height;
|
||||
cvRectangle(filter->cvImage, best_pos, corner, CV_RGB(255, 32, 32), 3, 8, 0);
|
||||
}
|
||||
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;
|
||||
corner.x += filter->cvTemplateImage->width;
|
||||
corner.y += filter->cvTemplateImage->height;
|
||||
cvRectangle (filter->cvImage, best_pos, corner, CV_RGB (255, 32, 32), 3,
|
||||
8, 0);
|
||||
}
|
||||
|
||||
|
||||
gst_buffer_set_data(buf, filter->cvImage->imageData, filter->cvImage->imageSize);
|
||||
}
|
||||
|
||||
return gst_pad_push (filter->srcpad, buf);
|
||||
|
||||
gst_buffer_set_data (buf, filter->cvImage->imageData,
|
||||
filter->cvImage->imageSize);
|
||||
|
||||
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)
|
||||
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;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -388,14 +400,14 @@ static void gst_templatematch_load_template(GstTemplateMatch *filter) {
|
|||
* initialize the plug-in itself
|
||||
* register the element factories and other features
|
||||
*/
|
||||
gboolean gst_templatematch_plugin_init (GstPlugin * templatematch)
|
||||
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");
|
||||
/* 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);
|
||||
return gst_element_register (templatematch, "templatematch", GST_RANK_NONE,
|
||||
GST_TYPE_TEMPLATEMATCH);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include <opencv/highgui.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define GST_TYPE_TEMPLATEMATCH \
|
||||
(gst_templatematch_get_type())
|
||||
|
@ -63,8 +62,7 @@ G_BEGIN_DECLS
|
|||
(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 _GstTemplateMatch GstTemplateMatch;
|
||||
typedef struct _GstTemplateMatchClass GstTemplateMatchClass;
|
||||
|
||||
struct _GstTemplateMatch
|
||||
|
@ -73,15 +71,15 @@ struct _GstTemplateMatch
|
|||
|
||||
GstPad *sinkpad, *srcpad;
|
||||
|
||||
gint method;
|
||||
gint method;
|
||||
gboolean display;
|
||||
|
||||
gchar *template;
|
||||
|
||||
IplImage *cvImage, *cvGray, *cvTemplateImage, *cvDistImage;
|
||||
IplImage *cvImage, *cvGray, *cvTemplateImage, *cvDistImage;
|
||||
};
|
||||
|
||||
struct _GstTemplateMatchClass
|
||||
struct _GstTemplateMatchClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
@ -91,5 +89,4 @@ GType gst_templatematch_get_type (void);
|
|||
gboolean gst_templatematch_plugin_init (GstPlugin * templatematch);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_TEMPLATEMATCH_H__ */
|
||||
|
|
Loading…
Reference in a new issue