blob: 0a99700b4aedad918094800c8894bcebc83c4378 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001SUMMARY = "Opencv : The Open Computer Vision Library"
2HOMEPAGE = "http://opencv.org/"
3SECTION = "libs"
4
5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=62d89c5dcb0583609ea919c56be0ee76"
7
8ARM_INSTRUCTION_SET_armv4 = "arm"
9ARM_INSTRUCTION_SET_armv5 = "arm"
10
11DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp"
12
13SRCREV_opencv = "b38c50b3d0c31e82294315ec44b54b7ef559ef12"
14SRCREV_contrib = "1f6d6f06266e1ef336437ae5404bee1c65d42cda"
15SRCREV_ipp = "bdb7bb85f34a8cb0d35e40a81f58da431aa1557a"
16SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26"
17SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
18SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59"
19SRC_URI[tinydnn.sha256sum] = "e2c61ce8c5debaa644121179e9dbdcf83f497f39de853f8dd5175846505aa18b"
20
21def ipp_filename(d):
22 import re
23 arch = d.getVar('TARGET_ARCH', True)
24 if re.match("i.86$", arch):
25 return "ippicv_2017u3_lnx_ia32_general_20180518.tgz"
26 else:
27 return "ippicv_2017u3_lnx_intel64_general_20180518.tgz"
28
29def ipp_md5sum(d):
30 import re
31 arch = d.getVar('TARGET_ARCH', True)
32 if re.match("i.86$", arch):
33 return "ea72de74dae3c604eb6348395366e78e"
34 else:
35 return "b7cc351267db2d34b9efa1cd22ff0572"
36
37IPP_FILENAME = "${@ipp_filename(d)}"
38IPP_MD5 = "${@ipp_md5sum(d)}"
39
40SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
41SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
42 git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \
43 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20180518;destsuffix=ipp;name=ipp \
44 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \
45 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \
46 https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz;destsuffix=git/3rdparty/tinydnn/tiny-dnn-1.0.0a3;name=tinydnn;unpack=false \
47 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
48 file://uselocalxfeatures.patch;patchdir=../contrib/ \
49 file://0001-Add-missing-multi-line-separator.patch;patchdir=../contrib/ \
50 file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \
51 file://0003-To-fix-errors-as-following.patch \
52 file://fixpkgconfig.patch \
53 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \
54 file://0001-Dont-use-isystem.patch \
55 file://0001-Check-for-clang-before-using-isystem.patch \
56"
57PV = "3.4.3+git${SRCPV}"
58
59S = "${WORKDIR}/git"
60
61do_unpack_extra() {
62 mkdir -p ${S}/3rdparty/tinydnn/
63 tar xzf ${WORKDIR}/v1.0.0a3.tar.gz -C ${S}/3rdparty/tinydnn/
64 tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR}
65 cp ${WORKDIR}/vgg/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src
66 cp ${WORKDIR}/boostdesc/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src
67}
68addtask unpack_extra after do_unpack before do_patch
69
70EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
71 -DWITH_1394=OFF \
72 -DENABLE_PRECOMPILED_HEADERS=OFF \
73 -DCMAKE_SKIP_RPATH=ON \
74 -DOPENCV_ICV_HASH=${IPP_MD5} \
75 -DIPPROOT=${WORKDIR}/ippicv_lnx \
76 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
77 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
78 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.2", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1 -DENABLE_SSE42=1", "", d)} \
79 ${@oe.utils.conditional("libdir", "/usr/lib64", "-DLIB_SUFFIX=64", "", d)} \
80 ${@oe.utils.conditional("libdir", "/usr/lib32", "-DLIB_SUFFIX=32", "", d)} \
81"
82EXTRA_OECMAKE_append_x86 = " -DX86=ON"
83
84PACKAGECONFIG ??= "python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
85 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
86 ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}"
87
88PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
89PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
90PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
91PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
92PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
93PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
94PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
95PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
96PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
97PACKAGECONFIG[java] = "-DJAVA_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native fastjar-native openjdk-8-native,"
98PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
99PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
100PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
101PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
102PACKAGECONFIG[oracle-java] = "-DJAVA_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${ORACLE_JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native oracle-jse-jdk oracle-jse-jdk-native,"
103PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
104PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
105PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
106PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
107PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
108PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
109PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
110PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
111
112inherit pkgconfig cmake
113
114inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
115inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
116
117export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
118export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
119export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
120export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
121export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
122
123TARGET_CC_ARCH += "-I${S}/include "
124
125PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
126 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
127 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
128 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
129 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
130 ${PN}-apps"
131
132python populate_packages_prepend () {
133 cv_libdir = d.expand('${libdir}')
134 do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
135 do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
136 do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
137 do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
138
139 pn = d.getVar('PN')
140 metapkg = pn + '-dev'
141 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
142 blacklist = [ metapkg ]
143 metapkg_rdepends = [ ]
144 packages = d.getVar('PACKAGES').split()
145 for pkg in packages[1:]:
146 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
147 metapkg_rdepends.append(pkg)
148 d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
149
150 metapkg = pn
151 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
152 blacklist = [ metapkg, "libopencv-ts" ]
153 metapkg_rdepends = [ ]
154 for pkg in packages[1:]:
155 if not pkg in blacklist and not pkg in metapkg_rdepends and not pkg.endswith('-dev') and not pkg.endswith('-dbg') and not pkg.endswith('-doc') and not pkg.endswith('-locale') and not pkg.endswith('-staticdev'):
156 metapkg_rdepends.append(pkg)
157 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
158}
159
160PACKAGES_DYNAMIC += "^libopencv-.*"
161
162FILES_${PN} = ""
163FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
164FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${datadir}/OpenCV/*.cmake"
165FILES_${PN}-staticdev += "${datadir}/OpenCV/3rdparty/lib/*.a"
166FILES_${PN}-apps = "${bindir}/* ${datadir}/OpenCV"
167FILES_${PN}-java = "${datadir}/OpenCV/java"
168FILES_${PN}-samples = "${datadir}/OpenCV/samples/"
169
170INSANE_SKIP_${PN}-java = "libdir"
171INSANE_SKIP_${PN}-dbg = "libdir"
172
173ALLOW_EMPTY_${PN} = "1"
174
175SUMMARY_python-opencv = "Python bindings to opencv"
176FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
177RDEPENDS_python-opencv = "python-core python-numpy"
178
179SUMMARY_python3-opencv = "Python bindings to opencv"
180FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
181RDEPENDS_python3-opencv = "python3-core python3-numpy"
182
183do_install_append() {
184 cp ${S}/include/opencv/*.h ${D}${includedir}/opencv/
185 sed -i '/blobtrack/d' ${D}${includedir}/opencv/cvaux.h
186
187 # Move Python files into correct library folder (for multilib build)
188 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
189 mv ${D}/usr/lib/* ${D}/${libdir}/
190 rm -rf ${D}/usr/lib
191 fi
192}