1if get_option('opencv').disabled() 2 subdir_done() 3endif 4 5gstopencv_sources = [ 6 'gstcvdilate.cpp', 7 'gstcvdilateerode.cpp', 8 'gstcvequalizehist.cpp', 9 'gstcverode.cpp', 10 'gstcvlaplace.cpp', 11 'gstcvsmooth.cpp', 12 'gstcvsobel.cpp', 13 'gstdisparity.cpp', 14 'gstedgedetect.cpp', 15 'gstfaceblur.cpp', 16 'gstfacedetect.cpp', 17 'gstgrabcut.cpp', 18 'gsthanddetect.cpp', 19 'gstmotioncells.cpp', 20 'gstopencv.cpp', 21 'gstretinex.cpp', 22 'gstsegmentation.cpp', 23 'gstskindetect.cpp', 24 'gsttemplatematch.cpp', 25 'gsttextoverlay.cpp', 26 'MotionCells.cpp', 27 'motioncells_wrapper.cpp', 28 'gstdewarp.cpp', 29 'camerautils.cpp', 30 'cameraevent.cpp', 31 'gstcameracalibrate.cpp', 32 'gstcameraundistort.cpp' 33] 34 35libopencv_headers = [ 36 'opencv2/bgsegm.hpp', 37 'opencv2/calib3d.hpp', 38 'opencv2/core.hpp', 39 'opencv2/imgproc.hpp', 40 'opencv2/objdetect.hpp', 41 'opencv2/opencv.hpp', 42 'opencv2/video.hpp', 43] 44 45libopencv4_headers = [ 46 'opencv4/opencv2/bgsegm.hpp', 47 'opencv4/opencv2/calib3d.hpp', 48 'opencv4/opencv2/core.hpp', 49 'opencv4/opencv2/imgproc.hpp', 50 'opencv4/opencv2/objdetect.hpp', 51 'opencv4/opencv2/opencv.hpp', 52 'opencv4/opencv2/video.hpp', 53] 54 55gstopencv_cargs = ['-DGST_HAAR_CASCADES_DIR="@0@"'] 56 57opencv_dep = dependency('opencv', version : ['>= 3.0.0', '< 3.5.0'], required : false) 58opencv_found = opencv_dep.found() 59 60if opencv_found 61 foreach h : libopencv_headers 62 if not cxx.has_header(h) 63 message('Needed header "' + h + '" not found') 64 opencv_found = false 65 endif 66 endforeach 67else 68 opencv_dep = dependency('opencv4', version : ['>= 4.0.0', '< 4.2.0'], required : false) 69 opencv_found = opencv_dep.found() 70 if opencv_found 71 foreach h : libopencv4_headers 72 if not cxx.has_header(h) 73 message('Needed header "' + h + '" not found') 74 opencv_found = false 75 endif 76 endforeach 77 endif 78endif 79 80if opencv_found 81 opencv_prefix = opencv_dep.get_pkgconfig_variable('prefix') 82 gstopencv_cargs += ['-DOPENCV_PREFIX="' + opencv_prefix + '"'] 83 84 # Check the data dir used by opencv for its xml data files 85 # Use prefix from pkg-config to be compatible with cross-compilation 86 r = run_command('test', '-d', opencv_prefix + '/share/opencv') 87 if r.returncode() == 0 88 gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv"' 89 else 90 r = run_command('test', '-d', opencv_prefix + '/share/OpenCV') 91 if r.returncode() == 0 92 gstopencv_cargs += '-DOPENCV_PATH_NAME="OpenCV"' 93 else 94 r = run_command('test', '-d', opencv_prefix + '/share/opencv4') 95 if r.returncode() == 0 96 gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv4"' 97 else 98 error('Unable to detect OpenCV data directory') 99 endif 100 endif 101 endif 102 gstopencv = library('gstopencv', 103 gstopencv_sources, 104 cpp_args : gst_plugins_bad_args + gstopencv_cargs + [ '-DGST_USE_UNSTABLE_API' ], 105 link_args : noseh_link_args, 106 include_directories : [configinc, libsinc], 107 dependencies : [gstbase_dep, gstvideo_dep, opencv_dep, gstopencv_dep], 108 install : true, 109 install_dir : plugins_install_dir, 110 ) 111 pkgconfig.generate(gstopencv, install_dir : plugins_pkgconfig_install_dir) 112elif get_option('opencv').enabled() 113 error('OpenCV support enabled but required dependencies were not found.') 114endif 115