diff --git a/ext/opencv/faceblur/gstfaceblur.c b/ext/opencv/faceblur/gstfaceblur.c index a33a708f72..bceb068cbc 100644 --- a/ext/opencv/faceblur/gstfaceblur.c +++ b/ext/opencv/faceblur/gstfaceblur.c @@ -272,6 +272,9 @@ gst_faceblur_chain (GstPad * pad, GstBuffer * buf) cvHaarDetectObjects (filter->cvGray, filter->cvCascade, filter->cvStorage, 1.1, 2, 0, cvSize (30, 30)); + if (faces && faces->total > 0) { + buf = gst_buffer_make_writable (buf); + } for (i = 0; i < (faces ? faces->total : 0); i++) { CvRect *r = (CvRect *) cvGetSeqElem (faces, i); cvSetImageROI (filter->cvImage, *r); @@ -279,11 +282,9 @@ gst_faceblur_chain (GstPad * pad, GstBuffer * buf) cvSmooth (filter->cvImage, filter->cvImage, CV_GAUSSIAN, 11, 11, 0, 0); cvResetImageROI (filter->cvImage); } - } - gst_buffer_set_data (buf, (guint8 *) filter->cvImage->imageData, - filter->cvImage->imageSize); + /* these filters operate in place, so we push the same buffer */ return gst_pad_push (filter->srcpad, buf); } diff --git a/ext/opencv/facedetect/gstfacedetect.c b/ext/opencv/facedetect/gstfacedetect.c index 6494e4399e..660add67d8 100644 --- a/ext/opencv/facedetect/gstfacedetect.c +++ b/ext/opencv/facedetect/gstfacedetect.c @@ -284,6 +284,10 @@ gst_facedetect_chain (GstPad * pad, GstBuffer * buf) cvHaarDetectObjects (filter->cvGray, filter->cvCascade, filter->cvStorage, 1.1, 2, 0, cvSize (30, 30)); + if (filter->display && faces && faces->total > 0) { + buf = gst_buffer_make_writable (buf); + } + for (i = 0; i < (faces ? faces->total : 0); i++) { CvRect *r = (CvRect *) cvGetSeqElem (faces, i); @@ -310,9 +314,6 @@ gst_facedetect_chain (GstPad * pad, GstBuffer * buf) } - gst_buffer_set_data (buf, (guint8 *) filter->cvImage->imageData, - filter->cvImage->imageSize); - return gst_pad_push (filter->srcpad, buf); } diff --git a/ext/opencv/templatematch/gsttemplatematch.c b/ext/opencv/templatematch/gsttemplatematch.c index 6dad35bb43..3821020b1f 100644 --- a/ext/opencv/templatematch/gsttemplatematch.c +++ b/ext/opencv/templatematch/gsttemplatematch.c @@ -310,13 +310,14 @@ gst_templatematch_chain (GstPad * pad, GstBuffer * buf) double best_res; filter = GST_TEMPLATEMATCH (GST_OBJECT_PARENT (pad)); - buf = gst_buffer_make_writable (buf); + + /* FIXME Why template == NULL returns OK? + * shouldn't it be a passthrough instead? */ 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 - @@ -344,6 +345,9 @@ gst_templatematch_chain (GstPad * pad, GstBuffer * buf) if (filter->display) { CvPoint corner = best_pos; + + buf = gst_buffer_make_writable (buf); + corner.x += filter->cvTemplateImage->width; corner.y += filter->cvTemplateImage->height; cvRectangle (filter->cvImage, best_pos, corner, CV_RGB (255, 32, 32), 3, @@ -352,10 +356,6 @@ gst_templatematch_chain (GstPad * pad, GstBuffer * buf) } - - gst_buffer_set_data (buf, (guint8 *) filter->cvImage->imageData, - filter->cvImage->imageSize); - return gst_pad_push (filter->srcpad, buf); } diff --git a/ext/opencv/textwrite/gsttextwrite.c b/ext/opencv/textwrite/gsttextwrite.c index 7e5684683b..287de3f43e 100644 --- a/ext/opencv/textwrite/gsttextwrite.c +++ b/ext/opencv/textwrite/gsttextwrite.c @@ -384,11 +384,9 @@ gst_textwrite_chain (GstPad * pad, GstBuffer * buf) cvInitFont(&(filter->font),CV_FONT_VECTOR0, filter->width,filter->height,0,filter->thickness,0); + buf = gst_buffer_make_writable (buf); cvPutText (filter->cvImage,filter->textbuf,cvPoint(filter->xpos,filter->ypos), &(filter->font), cvScalar(filter->colorR,filter->colorG,filter->colorB,0)); - gst_buffer_set_data (buf, (guint8 *) filter->cvImage->imageData, - filter->cvImage->imageSize); - return gst_pad_push (filter->srcpad, buf); }