Compare commits

...

5 Commits

View File

@ -81,6 +81,8 @@
#include <gst/opencv/gstopencvutils.h>
#include <opencv2/core/ocl.hpp>
GST_DEBUG_CATEGORY_STATIC (gst_camera_undistort_debug);
#define GST_CAT_DEFAULT gst_camera_undistort_debug
@ -324,8 +326,19 @@ camera_undistort_run (GstCameraUndistort * undist, cv::Mat img, cv::Mat outimg)
}
if (undist->showUndistorted && undist->doUndistort) {
/* Declare input and output images as UMat to enable potential OpenCL acceleration. */
/* UMat allows OpenCV to automatically use GPU if available and configured. */
cv::UMat cv_input_umat, cv_output_umat;
/* convert Mat to UMat */
img.copyTo(cv_input_umat);
/* do the undistort */
cv::remap (img, outimg, undist->map1, undist->map2, cv::INTER_LINEAR);
cv::remap (cv_input_umat, cv_output_umat, undist->map1, undist->map2, cv::INTER_LINEAR);
/* UMat output back to Mat */
cv_output_umat.copyTo(outimg);
if (undist->crop) {
/* TODO do the cropping */
@ -408,3 +421,4 @@ gst_camera_undistort_src_event (GstBaseTransform * trans, GstEvent * event)
GST_BASE_TRANSFORM_CLASS (gst_camera_undistort_parent_class)->src_event
(trans, event);
}