diff --git a/configure.ac b/configure.ac index d470287bd8..db1f3cb7d8 100644 --- a/configure.ac +++ b/configure.ac @@ -1885,7 +1885,7 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [ dnl a new version and the no-backward-compatibility define. (There doesn't dnl seem to be a switch to suppress the warnings the cvcompat.h header dnl causes.) - PKG_CHECK_MODULES(OPENCV, opencv >= 2.3.0 opencv < 3.5.0 , [ + PKG_CHECK_MODULES(OPENCV, opencv >= 3.0.0 opencv < 3.5.0 , [ AC_PROG_CXX AC_LANG([C++]) OLD_CPPFLAGS=$CPPFLAGS @@ -1897,13 +1897,8 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [ opencv2/imgproc/imgproc.hpp \ opencv2/imgproc/imgproc_c.h \ opencv2/objdetect/objdetect.hpp \ - opencv2/video/background_segm.hpp], [], [something_not_found=yes]) - - dnl Only required for OpenCV >= 3, we have compat code for older versions - PKG_CHECK_MODULES(OPENCV_3, opencv >= 3, [ - dnl check opencv_contrib headers (not always present in opencv distributions) - AC_CHECK_HEADERS([opencv2/bgsegm.hpp], [], [something_not_found=yes])], - [NOT_A_PROBLEM=yes]) + opencv2/video/background_segm.hpp \ + opencv2/bgsegm.hpp], [], [something_not_found=yes]) CPPFLAGS=$OLD_CPPFLAGS AC_LANG([C]) diff --git a/ext/opencv/MotionCells.cpp b/ext/opencv/MotionCells.cpp index 175ec901b2..c7f1a5ff06 100644 --- a/ext/opencv/MotionCells.cpp +++ b/ext/opencv/MotionCells.cpp @@ -42,19 +42,13 @@ * Boston, MA 02110-1301, USA. */ -/* This breaks the build for reasons that aren't entirely clear to me yet */ -#if 0 -//#ifdef HAVE_CONFIG_H -//#include "config.h" -//#endif +#ifdef HAVE_CONFIG_H +#include "config.h" #endif #include #include "MotionCells.h" -#if (CV_MAJOR_VERSION >= 3) #include -#endif -#include MotionCells::MotionCells () { diff --git a/ext/opencv/gstcameracalibrate.cpp b/ext/opencv/gstcameracalibrate.cpp index ba59a194b0..ec640c7eeb 100644 --- a/ext/opencv/gstcameracalibrate.cpp +++ b/ext/opencv/gstcameracalibrate.cpp @@ -84,9 +84,7 @@ #include "gstcameracalibrate.h" -#if (CV_MAJOR_VERSION >= 3) #include -#endif #include #include diff --git a/ext/opencv/gstcameraundistort.cpp b/ext/opencv/gstcameraundistort.cpp index a503008514..6e46524c0e 100644 --- a/ext/opencv/gstcameraundistort.cpp +++ b/ext/opencv/gstcameraundistort.cpp @@ -77,9 +77,7 @@ #include "gstcameraundistort.h" -#if (CV_MAJOR_VERSION >= 3) #include -#endif #include #include diff --git a/ext/opencv/gstdisparity.cpp b/ext/opencv/gstdisparity.cpp index 486e8656b2..82a314a345 100644 --- a/ext/opencv/gstdisparity.cpp +++ b/ext/opencv/gstdisparity.cpp @@ -120,10 +120,7 @@ gst-launch-1.0 multifilesrc location=~/im3.png ! pngdec ! videoconvert ! di #endif #include "gstdisparity.h" -#include -#if (CV_MAJOR_VERSION >= 3) #include -#endif GST_DEBUG_CATEGORY_STATIC (gst_disparity_debug); #define GST_CAT_DEFAULT gst_disparity_debug @@ -646,7 +643,7 @@ initialise_sbm (GstDisparity * filter) (void *) new Mat (cvarrToMat (filter->cvGray_left, false)); filter->depth_map_as_cvMat = (void *) new Mat (cvarrToMat (filter->cvGray_depth_map1, false)); -#if (CV_MAJOR_VERSION >= 3) + filter->sbm = StereoBM::create(); filter->sgbm = StereoSGBM::create(1,64,3); @@ -672,33 +669,6 @@ initialise_sbm (GstDisparity * filter) filter->sgbm->setSpeckleWindowSize (0); filter->sgbm->setSpeckleRange (0); filter->sgbm->setMode (StereoSGBM::MODE_HH); -#else - filter->sbm = (void *) new StereoBM (); - filter->sgbm = (void *) new StereoSGBM (); - - ((StereoBM *) filter->sbm)->state->SADWindowSize = 9; - ((StereoBM *) filter->sbm)->state->numberOfDisparities = 32; - ((StereoBM *) filter->sbm)->state->preFilterSize = 9; - ((StereoBM *) filter->sbm)->state->preFilterCap = 32; - ((StereoBM *) filter->sbm)->state->minDisparity = 0; - ((StereoBM *) filter->sbm)->state->textureThreshold = 0; - ((StereoBM *) filter->sbm)->state->uniquenessRatio = 0; - ((StereoBM *) filter->sbm)->state->speckleWindowSize = 0; - ((StereoBM *) filter->sbm)->state->speckleRange = 0; - ((StereoBM *) filter->sbm)->state->disp12MaxDiff = 0; - - ((StereoSGBM *) filter->sgbm)->minDisparity = 1; - ((StereoSGBM *) filter->sgbm)->numberOfDisparities = 64; - ((StereoSGBM *) filter->sgbm)->SADWindowSize = 3; - ((StereoSGBM *) filter->sgbm)->P1 = 200;; - ((StereoSGBM *) filter->sgbm)->P2 = 255; - ((StereoSGBM *) filter->sgbm)->disp12MaxDiff = 0; - ((StereoSGBM *) filter->sgbm)->preFilterCap = 0; - ((StereoSGBM *) filter->sgbm)->uniquenessRatio = 0; - ((StereoSGBM *) filter->sgbm)->speckleWindowSize = 0; - ((StereoSGBM *) filter->sgbm)->speckleRange = 0; - ((StereoSGBM *) filter->sgbm)->fullDP = true; -#endif return (0); } @@ -706,34 +676,22 @@ initialise_sbm (GstDisparity * filter) int run_sbm_iteration (GstDisparity * filter) { -#if (CV_MAJOR_VERSION >= 3) ((StereoBM *) filter-> sbm)->compute (*((Mat *) filter->img_left_as_cvMat_gray), *((Mat *) filter->img_right_as_cvMat_gray), *((Mat *) filter->depth_map_as_cvMat)); -#else - (*((StereoBM *) filter-> - sbm)) (*((Mat *) filter->img_left_as_cvMat_gray), - *((Mat *) filter->img_right_as_cvMat_gray), - *((Mat *) filter->depth_map_as_cvMat)); -#endif + return (0); } int run_sgbm_iteration (GstDisparity * filter) { -#if (CV_MAJOR_VERSION >= 3) ((StereoSGBM *) filter-> sgbm)->compute (*((Mat *) filter->img_left_as_cvMat_gray), *((Mat *) filter->img_right_as_cvMat_gray), *((Mat *) filter->depth_map_as_cvMat)); -#else - (*((StereoSGBM *) filter-> - sgbm)) (*((Mat *) filter->img_left_as_cvMat_gray), - *((Mat *) filter->img_right_as_cvMat_gray), - *((Mat *) filter->depth_map_as_cvMat)); -#endif + return (0); } @@ -743,12 +701,9 @@ finalise_sbm (GstDisparity * filter) delete (Mat *) filter->depth_map_as_cvMat; delete (Mat *) filter->img_left_as_cvMat_gray; delete (Mat *) filter->img_right_as_cvMat_gray; -#if (CV_MAJOR_VERSION >= 3) + filter->sbm.release(); filter->sgbm.release(); -#else - delete (StereoBM *) filter->sbm; - delete (StereoSGBM *) filter->sgbm; -#endif + return (0); } diff --git a/ext/opencv/gstdisparity.h b/ext/opencv/gstdisparity.h index 218699d137..863348e6a5 100644 --- a/ext/opencv/gstdisparity.h +++ b/ext/opencv/gstdisparity.h @@ -47,9 +47,8 @@ #include #include -#include -#include -#include +#include +#include G_BEGIN_DECLS /* #defines don't like whitespacey bits */ @@ -97,13 +96,9 @@ struct _GstDisparity void *img_right_as_cvMat_gray; /* cv::Mat */ void *img_left_as_cvMat_gray; /* cv::Mat */ void *depth_map_as_cvMat; /* cv::Mat */ -#if (CV_MAJOR_VERSION >= 3) + cv::Ptr sbm; /* cv::StereoBM */ cv::Ptr sgbm; /* cv::StereoSGBM */ -#else - void *sbm; /* cv::StereoBM */ - void *sgbm; /* cv::StereoSGBM */ -#endif }; struct _GstDisparityClass diff --git a/ext/opencv/gstfacedetect.cpp b/ext/opencv/gstfacedetect.cpp index 503b9e70f3..db6a1c4b58 100644 --- a/ext/opencv/gstfacedetect.cpp +++ b/ext/opencv/gstfacedetect.cpp @@ -81,9 +81,7 @@ using namespace std; #include "gstfacedetect.h" -#if (CV_MAJOR_VERSION >= 3) #include -#endif GST_DEBUG_CATEGORY_STATIC (gst_face_detect_debug); #define GST_CAT_DEFAULT gst_face_detect_debug diff --git a/ext/opencv/gsthanddetect.cpp b/ext/opencv/gsthanddetect.cpp index 47203fd0ea..9ef4851698 100644 --- a/ext/opencv/gsthanddetect.cpp +++ b/ext/opencv/gsthanddetect.cpp @@ -62,10 +62,7 @@ /* element header */ #include "gsthanddetect.h" -#if (CV_MAJOR_VERSION >= 3) #include -#endif -#include GST_DEBUG_CATEGORY_STATIC (gst_handdetect_debug); #define GST_CAT_DEFAULT gst_handdetect_debug diff --git a/ext/opencv/gstsegmentation.cpp b/ext/opencv/gstsegmentation.cpp index d52476e7d4..727ba9b09a 100644 --- a/ext/opencv/gstsegmentation.cpp +++ b/ext/opencv/gstsegmentation.cpp @@ -97,9 +97,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_segmentation_debug); #define GST_CAT_DEFAULT gst_segmentation_debug using namespace cv; -#if (CV_MAJOR_VERSION >= 3) - using namespace cv::bgsegm; -#endif +using namespace cv::bgsegm; + /* Filter signals and args */ enum { @@ -776,13 +775,8 @@ initialise_mog (GstSegmentation * filter) filter->img_input_as_cvMat = (void *) new Mat (cvarrToMat (filter->cvYUV, false)); filter->img_fg_as_cvMat = (void *) new Mat (cvarrToMat(filter->cvFG, false)); -#if (CV_MAJOR_VERSION >= 3) filter->mog = bgsegm::createBackgroundSubtractorMOG (); filter->mog2 = createBackgroundSubtractorMOG2 (); -#else - filter->mog = (void *) new BackgroundSubtractorMOG (); - filter->mog2 = (void *) new BackgroundSubtractorMOG2 (); -#endif return (0); } @@ -805,15 +799,9 @@ run_mog_iteration (GstSegmentation * filter) European Workshop on Advanced Video-Based Surveillance Systems, 2001 */ -#if (CV_MAJOR_VERSION >= 3) filter->mog->apply (*((Mat *) filter-> img_input_as_cvMat), *((Mat *) filter->img_fg_as_cvMat), filter->learning_rate); -#else - (*((BackgroundSubtractorMOG *) filter->mog)) (*((Mat *) filter-> - img_input_as_cvMat), *((Mat *) filter->img_fg_as_cvMat), - filter->learning_rate); -#endif return (0); } @@ -839,15 +827,9 @@ run_mog2_iteration (GstSegmentation * filter) Letters, vol. 27, no. 7, pages 773-780, 2006. */ -#if (CV_MAJOR_VERSION >= 3) filter->mog2->apply (*((Mat *) filter-> img_input_as_cvMat), *((Mat *) filter->img_fg_as_cvMat), filter->learning_rate); -#else - (*((BackgroundSubtractorMOG *) filter->mog2)) (*((Mat *) filter-> - img_input_as_cvMat), *((Mat *) filter->img_fg_as_cvMat), - filter->learning_rate); -#endif return (0); } @@ -857,12 +839,9 @@ finalise_mog (GstSegmentation * filter) { delete (Mat *) filter->img_input_as_cvMat; delete (Mat *) filter->img_fg_as_cvMat; -#if (CV_MAJOR_VERSION >= 3) + filter->mog.release (); filter->mog2.release (); -#else - delete (BackgroundSubtractorMOG *) filter->mog; - delete (BackgroundSubtractorMOG2 *) filter->mog2; -#endif + return (0); } diff --git a/ext/opencv/gstsegmentation.h b/ext/opencv/gstsegmentation.h index 20e42ca578..733f23c545 100644 --- a/ext/opencv/gstsegmentation.h +++ b/ext/opencv/gstsegmentation.h @@ -46,12 +46,10 @@ #include #include -#include -#include -#include -#if (CV_MAJOR_VERSION >= 3) - #include -#endif + +#include +#include +#include G_BEGIN_DECLS @@ -110,13 +108,9 @@ struct _GstSegmentation CvSeq *contours; /* for MOG methods */ -#if (CV_MAJOR_VERSION >= 3) cv::Ptr mog; /* cv::BackgroundSubtractorMOG */ cv::Ptr mog2; /* cv::BackgroundSubtractorMOG2 */ -#else - void *mog; /* cv::BackgroundSubtractorMOG */ - void *mog2; /* cv::BackgroundSubtractorMOG2 */ -#endif + void *img_input_as_cvMat; /* cv::Mat */ void *img_fg_as_cvMat; /* cv::Mat */ double learning_rate; diff --git a/ext/opencv/gsttemplatematch.cpp b/ext/opencv/gsttemplatematch.cpp index ec0b56af88..c390d1883f 100644 --- a/ext/opencv/gsttemplatematch.cpp +++ b/ext/opencv/gsttemplatematch.cpp @@ -63,10 +63,7 @@ #include "../../gst-libs/gst/gst-i18n-plugin.h" #include "gsttemplatematch.h" -#if (CV_MAJOR_VERSION >= 3) #include -#endif -#include GST_DEBUG_CATEGORY_STATIC (gst_template_match_debug); #define GST_CAT_DEFAULT gst_template_match_debug diff --git a/ext/opencv/gsttextoverlay.h b/ext/opencv/gsttextoverlay.h index 794cd79732..080904ec94 100644 --- a/ext/opencv/gsttextoverlay.h +++ b/ext/opencv/gsttextoverlay.h @@ -47,10 +47,9 @@ #define __GST_OPENCV_TEXT_OVERLAY_H__ #include -#include -#if (CV_MAJOR_VERSION >= 3) -#include -#endif +#include +#include + G_BEGIN_DECLS /* #defines don't like whitespacey bits */ diff --git a/ext/opencv/meson.build b/ext/opencv/meson.build index facf68c2af..4627565547 100644 --- a/ext/opencv/meson.build +++ b/ext/opencv/meson.build @@ -28,7 +28,7 @@ gstopencv_sources = [ 'gstcameraundistort.cpp' ] -libopencv2_headers = [ +libopencv_headers = [ 'opencv2/core/core_c.h', 'opencv2/core/version.hpp', 'opencv2/highgui/highgui_c.h', @@ -36,33 +36,21 @@ libopencv2_headers = [ 'opencv2/imgproc/imgproc_c.h', 'opencv2/objdetect/objdetect.hpp', 'opencv2/video/background_segm.hpp', -] - -libopencv3_headers = [ 'opencv2/bgsegm.hpp', ] gstopencv_cargs = ['-DGST_HAAR_CASCADES_DIR="@0@"'] -opencv_dep = dependency('opencv', version : ['>= 2.3.0', '< 3.5.0'], required : false) +opencv_dep = dependency('opencv', version : ['>= 3.0.0', '< 3.5.0'], required : false) opencv_found = opencv_dep.found() if opencv_found - foreach h : libopencv2_headers + foreach h : libopencv_headers if not cxx.has_header(h) message('Needed header "' + h + '" not found') opencv_found = false endif endforeach - - if opencv_dep.version() >= '3.0.0' - foreach h : libopencv3_headers - if not cxx.has_header(h) - message('Needed header "' + h + '" not found') - opencv_found = false - endif - endforeach - endif endif if opencv_found diff --git a/gst-libs/gst/opencv/meson.build b/gst-libs/gst/opencv/meson.build index b11e2ba343..222e861116 100644 --- a/gst-libs/gst/opencv/meson.build +++ b/gst-libs/gst/opencv/meson.build @@ -9,7 +9,7 @@ opencv_headers = [ 'gstopencvvideofilter.h', ] -opencv_dep = dependency('opencv', version : '>= 2.3.0', required : get_option('opencv')) +opencv_dep = dependency('opencv', version : '>= 3.0.0', required : get_option('opencv')) if opencv_dep.found() gstopencv = library('gstopencv-' + api_version, opencv_sources,