diff --git a/ext/opencv/edgedetect/gstedgedetect.c b/ext/opencv/edgedetect/gstedgedetect.c index 19cae79de0..26b4f47ba2 100644 --- a/ext/opencv/edgedetect/gstedgedetect.c +++ b/ext/opencv/edgedetect/gstedgedetect.c @@ -114,8 +114,24 @@ static void gst_edgedetect_get_property (GObject * object, guint prop_id, static gboolean gst_edgedetect_set_caps (GstPad * pad, GstCaps * caps); static GstFlowReturn gst_edgedetect_chain (GstPad * pad, GstBuffer * buf); -/* GObject vmethod implementations */ +/* Clean up */ +static void +gst_edgedetect_finalize (GObject * obj) +{ + Gstedgedetect *filter = GST_EDGEDETECT (obj); + if (filter->cvImage != NULL) + { + cvReleaseImage (&filter->cvImage); + cvReleaseImage (&filter->cvCEdge); + cvReleaseImage (&filter->cvGray); + cvReleaseImage (&filter->cvEdge); + } + + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +/* GObject vmethod implementations */ static void gst_edgedetect_base_init (gpointer gclass) { @@ -142,7 +158,9 @@ gst_edgedetect_class_init (GstedgedetectClass * klass) gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_edgedetect_finalize); gobject_class->set_property = gst_edgedetect_set_property; gobject_class->get_property = gst_edgedetect_get_property; @@ -294,7 +312,6 @@ gst_edgedetect_chain (GstPad * pad, GstBuffer * buf) return gst_pad_push (filter->srcpad, buf); } - /* entry point to initialize the plug-in * initialize the plug-in itself * register the element factories and other features diff --git a/ext/opencv/facedetect/gstfacedetect.c b/ext/opencv/facedetect/gstfacedetect.c index 0125c2809e..e1e6d70da3 100644 --- a/ext/opencv/facedetect/gstfacedetect.c +++ b/ext/opencv/facedetect/gstfacedetect.c @@ -114,8 +114,23 @@ static GstFlowReturn gst_facedetect_chain (GstPad * pad, GstBuffer * buf); static void gst_facedetect_load_profile (GObject * object); -/* GObject vmethod implementations */ +/* Clean up */ +static void +gst_facedetect_finalize (GObject * obj) +{ + Gstfacedetect *filter = GST_FACEDETECT(obj); + if (filter->cvImage) + { + cvReleaseImage (&filter->cvImage); + cvReleaseImage (&filter->cvGray); + } + + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + + +/* GObject vmethod implementations */ static void gst_facedetect_base_init (gpointer gclass) { @@ -142,7 +157,9 @@ gst_facedetect_class_init (GstfacedetectClass * klass) gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_facedetect_finalize); gobject_class->set_property = gst_facedetect_set_property; gobject_class->get_property = gst_facedetect_get_property; diff --git a/ext/opencv/pyramidsegment/gstpyramidsegment.c b/ext/opencv/pyramidsegment/gstpyramidsegment.c index 43dd502bf2..811baead20 100644 --- a/ext/opencv/pyramidsegment/gstpyramidsegment.c +++ b/ext/opencv/pyramidsegment/gstpyramidsegment.c @@ -112,8 +112,22 @@ static void gst_pyramidsegment_get_property (GObject * object, guint prop_id, static gboolean gst_pyramidsegment_set_caps (GstPad * pad, GstCaps * caps); static GstFlowReturn gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf); -/* GObject vmethod implementations */ +/* Clean up */ +static void +gst_pyramidsegment_finalize (GObject * obj) +{ + Gstpyramidsegment *filter = GST_PYRAMIDSEGMENT(obj); + if (filter->cvImage != NULL) + { + cvReleaseImage (&filter->cvImage); + cvReleaseImage (&filter->cvSegmentedImage); + } + + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +/* GObject vmethod implementations */ static void gst_pyramidsegment_base_init (gpointer gclass) { @@ -140,7 +154,9 @@ gst_pyramidsegment_class_init (GstpyramidsegmentClass * klass) gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_pyramidsegment_finalize); gobject_class->set_property = gst_pyramidsegment_set_property; gobject_class->get_property = gst_pyramidsegment_get_property;