2018-12-17 18:58:52 +00:00
|
|
|
if get_option('opencv').disabled()
|
2020-09-10 17:35:11 +00:00
|
|
|
opencv_dep = disabler()
|
2018-12-17 18:58:52 +00:00
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
2016-11-28 20:11:28 +00:00
|
|
|
gstopencv_sources = [
|
2016-11-15 16:57:20 +00:00
|
|
|
'gstcvdilate.cpp',
|
|
|
|
'gstcvdilateerode.cpp',
|
|
|
|
'gstcvequalizehist.cpp',
|
|
|
|
'gstcverode.cpp',
|
|
|
|
'gstcvlaplace.cpp',
|
|
|
|
'gstcvsmooth.cpp',
|
|
|
|
'gstcvsobel.cpp',
|
|
|
|
'gstdisparity.cpp',
|
|
|
|
'gstedgedetect.cpp',
|
|
|
|
'gstfaceblur.cpp',
|
|
|
|
'gstfacedetect.cpp',
|
|
|
|
'gstgrabcut.cpp',
|
|
|
|
'gsthanddetect.cpp',
|
|
|
|
'gstmotioncells.cpp',
|
|
|
|
'gstopencv.cpp',
|
|
|
|
'gstretinex.cpp',
|
|
|
|
'gstsegmentation.cpp',
|
|
|
|
'gstskindetect.cpp',
|
|
|
|
'gsttemplatematch.cpp',
|
|
|
|
'gsttextoverlay.cpp',
|
|
|
|
'MotionCells.cpp',
|
2016-12-14 09:37:14 +00:00
|
|
|
'motioncells_wrapper.cpp',
|
2017-10-16 20:29:01 +00:00
|
|
|
'gstdewarp.cpp',
|
|
|
|
'camerautils.cpp',
|
|
|
|
'cameraevent.cpp',
|
|
|
|
'gstcameracalibrate.cpp',
|
2020-05-24 18:07:25 +00:00
|
|
|
'gstcameraundistort.cpp',
|
|
|
|
'gstcvtracker.cpp'
|
2016-11-15 16:57:20 +00:00
|
|
|
]
|
|
|
|
|
2018-08-02 14:39:14 +00:00
|
|
|
libopencv_headers = [
|
2016-12-02 03:02:51 +00:00
|
|
|
'opencv2/bgsegm.hpp',
|
2018-08-02 15:19:07 +00:00
|
|
|
'opencv2/calib3d.hpp',
|
|
|
|
'opencv2/core.hpp',
|
|
|
|
'opencv2/imgproc.hpp',
|
|
|
|
'opencv2/objdetect.hpp',
|
|
|
|
'opencv2/opencv.hpp',
|
|
|
|
'opencv2/video.hpp',
|
2020-05-24 18:07:25 +00:00
|
|
|
'opencv2/tracking.hpp',
|
2016-11-28 20:11:28 +00:00
|
|
|
]
|
|
|
|
|
2018-11-25 15:13:28 +00:00
|
|
|
libopencv4_headers = [
|
|
|
|
'opencv4/opencv2/bgsegm.hpp',
|
|
|
|
'opencv4/opencv2/calib3d.hpp',
|
|
|
|
'opencv4/opencv2/core.hpp',
|
|
|
|
'opencv4/opencv2/imgproc.hpp',
|
|
|
|
'opencv4/opencv2/objdetect.hpp',
|
|
|
|
'opencv4/opencv2/opencv.hpp',
|
|
|
|
'opencv4/opencv2/video.hpp',
|
2020-05-24 18:07:25 +00:00
|
|
|
'opencv4/opencv2/tracking.hpp',
|
2018-11-25 15:13:28 +00:00
|
|
|
]
|
|
|
|
|
2016-11-28 20:11:28 +00:00
|
|
|
gstopencv_cargs = ['-DGST_HAAR_CASCADES_DIR="@0@"']
|
2016-11-15 16:57:20 +00:00
|
|
|
|
2018-08-02 14:39:14 +00:00
|
|
|
opencv_dep = dependency('opencv', version : ['>= 3.0.0', '< 3.5.0'], required : false)
|
2017-05-09 19:06:52 +00:00
|
|
|
opencv_found = opencv_dep.found()
|
2016-11-28 20:11:28 +00:00
|
|
|
|
2017-05-09 19:06:52 +00:00
|
|
|
if opencv_found
|
2018-08-02 14:39:14 +00:00
|
|
|
foreach h : libopencv_headers
|
2016-11-28 20:11:28 +00:00
|
|
|
if not cxx.has_header(h)
|
|
|
|
message('Needed header "' + h + '" not found')
|
2017-05-09 17:16:50 +00:00
|
|
|
opencv_found = false
|
2016-11-28 20:11:28 +00:00
|
|
|
endif
|
|
|
|
endforeach
|
2020-05-25 05:05:30 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if not opencv_found
|
2020-10-18 15:59:44 +00:00
|
|
|
opencv_dep = dependency('opencv4', version : ['>= 4.0.0', '< 4.6.0'], required : false)
|
2018-11-25 15:13:28 +00:00
|
|
|
opencv_found = opencv_dep.found()
|
|
|
|
if opencv_found
|
|
|
|
foreach h : libopencv4_headers
|
|
|
|
if not cxx.has_header(h)
|
|
|
|
message('Needed header "' + h + '" not found')
|
|
|
|
opencv_found = false
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
endif
|
2016-11-15 16:57:20 +00:00
|
|
|
endif
|
|
|
|
|
2017-05-09 17:16:50 +00:00
|
|
|
if opencv_found
|
2021-10-17 23:40:14 +00:00
|
|
|
opencv_prefix = opencv_dep.get_variable('prefix')
|
2017-05-09 17:16:50 +00:00
|
|
|
gstopencv_cargs += ['-DOPENCV_PREFIX="' + opencv_prefix + '"']
|
2016-11-28 20:11:28 +00:00
|
|
|
|
|
|
|
# Check the data dir used by opencv for its xml data files
|
|
|
|
# Use prefix from pkg-config to be compatible with cross-compilation
|
2022-01-04 20:37:59 +00:00
|
|
|
r = run_command('test', '-d', opencv_prefix + '/share/opencv', check: false)
|
2016-11-28 20:11:28 +00:00
|
|
|
if r.returncode() == 0
|
|
|
|
gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv"'
|
|
|
|
else
|
2022-01-04 20:37:59 +00:00
|
|
|
r = run_command('test', '-d', opencv_prefix + '/share/OpenCV', check: false)
|
2016-11-28 20:11:28 +00:00
|
|
|
if r.returncode() == 0
|
2018-02-06 10:36:27 +00:00
|
|
|
gstopencv_cargs += '-DOPENCV_PATH_NAME="OpenCV"'
|
2016-11-28 20:11:28 +00:00
|
|
|
else
|
2022-01-04 20:37:59 +00:00
|
|
|
r = run_command('test', '-d', opencv_prefix + '/share/opencv4', check: false)
|
2018-11-25 15:13:28 +00:00
|
|
|
if r.returncode() == 0
|
|
|
|
gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv4"'
|
|
|
|
else
|
2019-10-24 13:40:25 +00:00
|
|
|
message('Unable to detect OpenCV data directory')
|
|
|
|
opencv_found = false
|
2018-11-25 15:13:28 +00:00
|
|
|
endif
|
2016-11-28 20:11:28 +00:00
|
|
|
endif
|
|
|
|
endif
|
2019-10-24 13:40:25 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
if opencv_found
|
2020-07-10 13:56:50 +00:00
|
|
|
# opencv4 seems to ship with .pc file that references non-existent include dir
|
|
|
|
# (/usr/include/opencv4/opencv instead of /usr/include/opencv4/opencv2)
|
2020-08-05 09:35:12 +00:00
|
|
|
# clang 10 complains about the following header in opencv4
|
|
|
|
# /usr/include/opencv4/opencv2/flann/logger.h:83:36: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
|
|
|
|
gstopencv_cargs += cxx.get_supported_arguments(['-Wno-missing-include-dirs', '-Wno-format-nonliteral'])
|
2020-07-10 13:56:50 +00:00
|
|
|
|
2016-11-15 16:57:20 +00:00
|
|
|
gstopencv = library('gstopencv',
|
2016-11-28 20:11:28 +00:00
|
|
|
gstopencv_sources,
|
|
|
|
cpp_args : gst_plugins_bad_args + gstopencv_cargs + [ '-DGST_USE_UNSTABLE_API' ],
|
2020-05-24 18:07:25 +00:00
|
|
|
link_args : [noseh_link_args, '-lopencv_tracking'],
|
2018-12-17 10:30:27 +00:00
|
|
|
include_directories : [configinc, libsinc],
|
2017-05-09 17:16:50 +00:00
|
|
|
dependencies : [gstbase_dep, gstvideo_dep, opencv_dep, gstopencv_dep],
|
2016-11-15 16:57:20 +00:00
|
|
|
install : true,
|
|
|
|
install_dir : plugins_install_dir,
|
|
|
|
)
|
2018-04-24 18:05:30 +00:00
|
|
|
pkgconfig.generate(gstopencv, install_dir : plugins_pkgconfig_install_dir)
|
2018-10-22 09:30:45 +00:00
|
|
|
plugins += [gstopencv]
|
2018-12-17 18:58:52 +00:00
|
|
|
elif get_option('opencv').enabled()
|
|
|
|
error('OpenCV support enabled but required dependencies were not found.')
|
2016-11-15 16:57:20 +00:00
|
|
|
endif
|