summaryrefslogtreecommitdiff
path: root/ext/opencv
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2016-12-01 21:36:13 -0500
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2016-12-01 21:56:09 -0500
commit02b20f6158a859bed3aec066d740333c3e868585 (patch)
tree4ac9670326d57b5809cd44890d516e90cc95dc48 /ext/opencv
parent7a284f1a86103bc6602afd4aa17afd4f4e357b58 (diff)
cvsobel: Avoid extra copy of the output image
Simply produce the result into the output image provided by the base class. This avoid useless copy. This also removes unchecked buffer map and ensure that GstVideoMeta is respected (for stride mostly). https://bugzilla.gnome.org/show_bug.cgi?id=775377
Diffstat (limited to 'ext/opencv')
-rw-r--r--ext/opencv/gstcvsobel.cpp14
-rw-r--r--ext/opencv/gstcvsobel.h1
2 files changed, 3 insertions, 12 deletions
diff --git a/ext/opencv/gstcvsobel.cpp b/ext/opencv/gstcvsobel.cpp
index a7197d9c3..8c329cbd9 100644
--- a/ext/opencv/gstcvsobel.cpp
+++ b/ext/opencv/gstcvsobel.cpp
@@ -116,7 +116,6 @@ gst_cv_sobel_finalize (GObject * obj)
GstCvSobel *filter = GST_CV_SOBEL (obj);
if (filter->cvSobel != NULL) {
- cvReleaseImage (&filter->cvCSobel);
cvReleaseImage (&filter->cvGray);
cvReleaseImage (&filter->cvSobel);
}
@@ -192,12 +191,10 @@ gst_cv_sobel_set_caps (GstOpencvVideoFilter * transform,
GstCvSobel *filter = GST_CV_SOBEL (transform);
if (filter->cvSobel != NULL) {
- cvReleaseImage (&filter->cvCSobel);
cvReleaseImage (&filter->cvGray);
cvReleaseImage (&filter->cvSobel);
}
- filter->cvCSobel = cvCreateImage (cvSize (in_width, in_height), IPL_DEPTH_8U, in_channels);
filter->cvGray = cvCreateImage (cvSize (in_width, in_height), IPL_DEPTH_8U, 1);
filter->cvSobel = cvCreateImage (cvSize (out_width, out_height), IPL_DEPTH_8U, 1);
@@ -265,23 +262,18 @@ gst_cv_sobel_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
IplImage * img, GstBuffer * outbuf, IplImage * outimg)
{
GstCvSobel *filter = GST_CV_SOBEL (base);
- GstMapInfo out_info;
cvCvtColor (img, filter->cvGray, CV_RGB2GRAY);
cvSobel (filter->cvGray, filter->cvSobel, filter->x_order, filter->y_order,
filter->aperture_size);
- cvZero (filter->cvCSobel);
+ cvZero (outimg);
if (filter->mask) {
- cvCopy (img, filter->cvCSobel, filter->cvSobel);
+ cvCopy (img, outimg, filter->cvSobel);
} else {
- cvCvtColor (filter->cvSobel, filter->cvCSobel, CV_GRAY2RGB);
+ cvCvtColor (filter->cvSobel, outimg, CV_GRAY2RGB);
}
- gst_buffer_map (outbuf, &out_info, GST_MAP_WRITE);
- memcpy (out_info.data, filter->cvCSobel->imageData,
- gst_buffer_get_size (outbuf));
-
return GST_FLOW_OK;
}
diff --git a/ext/opencv/gstcvsobel.h b/ext/opencv/gstcvsobel.h
index ffe78d81a..616bfd3d3 100644
--- a/ext/opencv/gstcvsobel.h
+++ b/ext/opencv/gstcvsobel.h
@@ -72,7 +72,6 @@ struct _GstCvSobel
gint aperture_size;
gboolean mask;
- IplImage *cvCSobel;
IplImage *cvGray;
IplImage *cvSobel;
};