1 if get_option('opencv').disabled()
2 opencv_dep = disabler()
8 'gstcvdilateerode.cpp',
9 'gstcvequalizehist.cpp',
23 'gstsegmentation.cpp',
25 'gsttemplatematch.cpp',
28 'motioncells_wrapper.cpp',
32 'gstcameracalibrate.cpp',
33 'gstcameraundistort.cpp',
39 'opencv2/calib3d.hpp',
41 'opencv2/imgproc.hpp',
42 'opencv2/objdetect.hpp',
45 'opencv2/tracking.hpp',
48 libopencv4_headers = [
49 'opencv4/opencv2/bgsegm.hpp',
50 'opencv4/opencv2/calib3d.hpp',
51 'opencv4/opencv2/core.hpp',
52 'opencv4/opencv2/imgproc.hpp',
53 'opencv4/opencv2/objdetect.hpp',
54 'opencv4/opencv2/opencv.hpp',
55 'opencv4/opencv2/video.hpp',
56 'opencv4/opencv2/tracking.hpp',
59 gstopencv_cargs = ['-DGST_HAAR_CASCADES_DIR="@0@"']
61 opencv_dep = dependency('opencv', version : ['>= 3.0.0', '< 3.5.0'], required : false)
62 opencv_found = opencv_dep.found()
65 foreach h : libopencv_headers
66 if not cxx.has_header(h)
67 message('Needed header "' + h + '" not found')
74 opencv_dep = dependency('opencv4', version : ['>= 4.0.0', '< 4.7.0'], required : false)
75 opencv_found = opencv_dep.found()
77 foreach h : libopencv4_headers
78 if not cxx.has_header(h)
79 message('Needed header "' + h + '" not found')
87 opencv_prefix = opencv_dep.get_variable('prefix')
88 gstopencv_cargs += ['-DOPENCV_PREFIX="' + opencv_prefix + '"']
90 # Check the data dir used by opencv for its xml data files
91 # Use prefix from pkg-config to be compatible with cross-compilation
92 r = run_command('test', '-d', opencv_prefix + '/share/opencv', check: false)
93 if r.returncode() == 0
94 gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv"'
96 r = run_command('test', '-d', opencv_prefix + '/share/OpenCV', check: false)
97 if r.returncode() == 0
98 gstopencv_cargs += '-DOPENCV_PATH_NAME="OpenCV"'
100 r = run_command('test', '-d', opencv_prefix + '/share/opencv4', check: false)
101 if r.returncode() == 0
102 gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv4"'
104 message('Unable to detect OpenCV data directory')
112 # opencv4 seems to ship with .pc file that references non-existent include dir
113 # (/usr/include/opencv4/opencv instead of /usr/include/opencv4/opencv2)
114 # clang 10 complains about the following header in opencv4
115 # /usr/include/opencv4/opencv2/flann/logger.h:83:36: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
116 gstopencv_cargs += cxx.get_supported_arguments(['-Wno-missing-include-dirs', '-Wno-format-nonliteral'])
118 gstopencv = library('gstopencv',
120 cpp_args : gst_plugins_bad_args + gstopencv_cargs + [ '-DGST_USE_UNSTABLE_API' ],
121 link_args : [noseh_link_args, '-lopencv_tracking'],
122 include_directories : [configinc, libsinc],
123 dependencies : [gstbase_dep, gstvideo_dep, opencv_dep, gstopencv_dep],
125 install_dir : plugins_install_dir,
127 plugins += [gstopencv]
128 elif get_option('opencv').enabled()
129 error('OpenCV support enabled but required dependencies were not found.')