summaryrefslogtreecommitdiff
path: root/ext/opencv/gstcvsobel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ext/opencv/gstcvsobel.cpp')
-rw-r--r--ext/opencv/gstcvsobel.cpp44
1 files changed, 16 insertions, 28 deletions
diff --git a/ext/opencv/gstcvsobel.cpp b/ext/opencv/gstcvsobel.cpp
index 7601ba772..ffeeba572 100644
--- a/ext/opencv/gstcvsobel.cpp
+++ b/ext/opencv/gstcvsobel.cpp
@@ -60,9 +60,6 @@
#include "gstcvsobel.h"
#include <opencv2/imgproc.hpp>
-#if (CV_MAJOR_VERSION >= 4)
-#include <opencv2/imgproc/imgproc_c.h>
-#endif
GST_DEBUG_CATEGORY_STATIC (gst_cv_sobel_debug);
#define GST_CAT_DEFAULT gst_cv_sobel_debug
@@ -107,10 +104,10 @@ static void gst_cv_sobel_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstFlowReturn gst_cv_sobel_transform (GstOpencvVideoFilter * filter,
- GstBuffer * buf, IplImage * img, GstBuffer * outbuf, IplImage * outimg);
+ GstBuffer * buf, cv::Mat img, GstBuffer * outbuf, cv::Mat outimg);
static gboolean gst_cv_sobel_set_caps (GstOpencvVideoFilter * transform,
- gint in_width, gint in_height, gint in_depth, gint in_channels,
- gint out_width, gint out_height, gint out_depth, gint out_channels);
+ gint in_width, gint in_height, int in_cv_type,
+ gint out_width, gint out_height, int out_cv_type);
/* Clean up */
static void
@@ -118,10 +115,8 @@ gst_cv_sobel_finalize (GObject * obj)
{
GstCvSobel *filter = GST_CV_SOBEL (obj);
- if (filter->cvSobel != NULL) {
- cvReleaseImage (&filter->cvGray);
- cvReleaseImage (&filter->cvSobel);
- }
+ filter->cvGray.release ();
+ filter->cvSobel.release ();
G_OBJECT_CLASS (gst_cv_sobel_parent_class)->finalize (obj);
}
@@ -189,20 +184,13 @@ gst_cv_sobel_init (GstCvSobel * filter)
/* this function handles the link with other elements */
static gboolean
gst_cv_sobel_set_caps (GstOpencvVideoFilter * transform,
- gint in_width, gint in_height, gint in_depth, gint in_channels,
- gint out_width, gint out_height, gint out_depth, gint out_channels)
+ gint in_width, gint in_height, int in_cv_type,
+ gint out_width, gint out_height, int out_cv_type)
{
GstCvSobel *filter = GST_CV_SOBEL (transform);
- if (filter->cvSobel != NULL) {
- cvReleaseImage (&filter->cvGray);
- cvReleaseImage (&filter->cvSobel);
- }
-
- filter->cvGray =
- cvCreateImage (cvSize (in_width, in_height), IPL_DEPTH_8U, 1);
- filter->cvSobel =
- cvCreateImage (cvSize (out_width, out_height), IPL_DEPTH_8U, 1);
+ filter->cvGray.create (cv::Size (in_width, in_height), CV_8UC1);
+ filter->cvSobel.create (cv::Size (out_width, out_height), CV_8UC1);
return TRUE;
}
@@ -265,19 +253,19 @@ gst_cv_sobel_get_property (GObject * object, guint prop_id,
static GstFlowReturn
gst_cv_sobel_transform (GstOpencvVideoFilter * base, GstBuffer * buf,
- IplImage * img, GstBuffer * outbuf, IplImage * outimg)
+ cv::Mat img, GstBuffer * outbuf, cv::Mat outimg)
{
GstCvSobel *filter = GST_CV_SOBEL (base);
- cvCvtColor (img, filter->cvGray, CV_RGB2GRAY);
- cvSobel (filter->cvGray, filter->cvSobel, filter->x_order, filter->y_order,
- filter->aperture_size);
+ cv::cvtColor (img, filter->cvGray, cv::COLOR_RGB2GRAY);
+ cv::Sobel (filter->cvGray, filter->cvSobel, filter->cvGray.depth (),
+ filter->x_order, filter->y_order, filter->aperture_size);
- cvZero (outimg);
+ outimg.setTo (cv::Scalar::all (0));
if (filter->mask) {
- cvCopy (img, outimg, filter->cvSobel);
+ img.copyTo (outimg, filter->cvSobel);
} else {
- cvCvtColor (filter->cvSobel, outimg, CV_GRAY2RGB);
+ cv::cvtColor (filter->cvSobel, outimg, cv::COLOR_GRAY2RGB);
}
return GST_FLOW_OK;