diff --git a/configure.ac b/configure.ac index cea3e7ec60..7444c57492 100644 --- a/configure.ac +++ b/configure.ac @@ -2730,8 +2730,13 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [ opencv2/imgproc/imgproc_c.h \ opencv2/objdetect/objdetect.hpp \ opencv2/video/background_segm.hpp], [], [something_not_found=yes]) - dnl check opencv_contrib headers (not always present in opencv distributions) - AC_CHECK_HEADERS([opencv2/bgsegm.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]) + CPPFLAGS=$OLD_CPPFLAGS AC_LANG([C]) diff --git a/ext/opencv/meson.build b/ext/opencv/meson.build index 59002c7d6f..aa55d14337 100644 --- a/ext/opencv/meson.build +++ b/ext/opencv/meson.build @@ -32,6 +32,9 @@ libopencv2_headers = [ 'opencv2/imgproc/imgproc_c.h', 'opencv2/objdetect/objdetect.hpp', 'opencv2/video/background_segm.hpp', +] + +libopencv3_headers = [ 'opencv2/bgsegm.hpp', ] @@ -39,13 +42,14 @@ gstopencv_cargs = ['-DGST_HAAR_CASCADES_DIR="@0@"'] # First, check for the upper version limit and ensure it isn't found # FIXME: When 0.37.0 is released, change this to use many-version-conditions -opencv3_dep = dependency('opencv', version : '>3.1.0', required : false) +opencv3_1_dep = dependency('opencv', version : '>3.1.0', required : false) # Then, check if the lower version limit is found opencv2_dep = dependency('opencv', version : '>=2.3.0', required : false) +opencv3_dep = dependency('opencv', version : '>= 3.0 ', required : false) opencv2_found = false -if opencv3_dep.found() - message('OpenCV version is too new: \'' + opencv3_dep.version() + '\' (need <= 3.1.0)') +if opencv3_1_dep.found() + message('OpenCV version is too new: \'' + opencv3_1_dep.version() + '\' (need <= 3.1.0)') elif opencv2_dep.found() message('OpenCV found, version is \'' + opencv2_dep.version() + '\'') opencv2_found = true @@ -55,6 +59,15 @@ elif opencv2_dep.found() opencv2_found = false endif endforeach + + if opencv3_dep.found() + foreach h : libopencv3_headers + if not cxx.has_header(h) + message('Needed header "' + h + '" not found') + opencv2_found = false + endif + endforeach + endif endif if opencv2_found