mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
faceblur: facedetect: templatematch: textwrite: Set buffer to writable
These elements operates in place, set buffer to writable before operating.
This commit is contained in:
parent
42984056db
commit
5a9d9a8ae0
4 changed files with 15 additions and 15 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue