summaryrefslogtreecommitdiff
path: root/ext/opencv/meson.build
blob: 59002c7d6fa2a54a2d19b61911a6b73dcef3fd78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
gstopencv_sources = [
  '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',
  'motioncells_wrapper.cpp',
  'gstdewarp.cpp'
]

libopencv2_headers = [
  'opencv2/core/core_c.h',
  'opencv2/core/version.hpp',
  'opencv2/highgui/highgui_c.h',
  'opencv2/imgproc/imgproc.hpp',
  'opencv2/imgproc/imgproc_c.h',
  'opencv2/objdetect/objdetect.hpp',
  'opencv2/video/background_segm.hpp',
  'opencv2/bgsegm.hpp',
]

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)
# Then, check if the lower version limit is found
opencv2_dep = dependency('opencv', version : '>=2.3.0', required : false)

opencv2_found = false
if opencv3_dep.found()
  message('OpenCV version is too new: \'' + opencv3_dep.version() + '\' (need <= 3.1.0)')
elif opencv2_dep.found()
  message('OpenCV found, version is \'' + opencv2_dep.version() + '\'')
  opencv2_found = true
  foreach h : libopencv2_headers
    if not cxx.has_header(h)
      message('Needed header "' + h + '" not found')
      opencv2_found = false
    endif
  endforeach
endif

if opencv2_found
  opencv2_prefix = opencv2_dep.get_pkgconfig_variable('prefix')
  gstopencv_cargs += ['-DOPENCV_PREFIX="' + opencv2_prefix + '"']

  # Check the data dir used by opencv for its xml data files
  # Use prefix from pkg-config to be compatible with cross-compilation
  r = run_command('test', '-d', opencv2_prefix + '/share/opencv')
  if r.returncode() == 0
    gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv"'
  else
    r = run_command('test', '-d', opencv2_prefix + '/share/OpenCV')
    if r.returncode() == 0
      gstopencv_cargs += '-DOPENCV_PATH_NAME="OpenCv"'
    else
      error('Unable to detect OpenCV data directory')
    endif
  endif
  gstopencv = library('gstopencv',
    gstopencv_sources,
    cpp_args : gst_plugins_bad_args + gstopencv_cargs + [ '-DGST_USE_UNSTABLE_API' ],
    link_args : noseh_link_args,
    include_directories : [configinc],
    dependencies : [gstbase_dep, gstvideo_dep, opencv2_dep, gstopencv_dep],
    install : true,
    install_dir : plugins_install_dir,
  )
endif