blob: 5e89db0977d9fb8388d8914e0440ff19621d9f67 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001SUMMARY = "Opencv : The Open Computer Vision Library"
2HOMEPAGE = "http://opencv.org/"
3SECTION = "libs"
4
5LICENSE = "BSD-3-Clause"
Brad Bishop26bdd442019-08-16 17:08:17 -04006LIC_FILES_CHKSUM = "file://LICENSE;md5=6450921bb12a3133c8f5cb2a80343710"
Brad Bishop19323692019-04-05 15:28:33 -04007
8ARM_INSTRUCTION_SET_armv4 = "arm"
9ARM_INSTRUCTION_SET_armv5 = "arm"
10
11DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp"
12
Brad Bishop26bdd442019-08-16 17:08:17 -040013SRCREV_opencv = "371bba8f54560b374fbcd47e7e02f015ac4969ad"
14SRCREV_contrib = "2c32791a9c500343568a21ea34bf2daeac2adae7"
Brad Bishop19323692019-04-05 15:28:33 -040015SRCREV_ipp = "32e315a5b106a7b89dbed51c28f8120a48b368b4"
16SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26"
17SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
Brad Bishop19323692019-04-05 15:28:33 -040018
19def ipp_filename(d):
20 import re
21 arch = d.getVar('TARGET_ARCH')
22 if re.match("i.86$", arch):
23 return "ippicv_2019_lnx_ia32_general_20180723.tgz"
24 else:
25 return "ippicv_2019_lnx_intel64_general_20180723.tgz"
26
27def ipp_md5sum(d):
28 import re
29 arch = d.getVar('TARGET_ARCH')
30 if re.match("i.86$", arch):
31 return "4f38432c30bfd6423164b7a24bbc98a0"
32 else:
33 return "c0bd78adb4156bbf552c1dfe90599607"
34
35IPP_FILENAME = "${@ipp_filename(d)}"
36IPP_MD5 = "${@ipp_md5sum(d)}"
37
38SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
39SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
Brad Bishop26bdd442019-08-16 17:08:17 -040040 git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \
41 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20180723;destsuffix=ipp;name=ipp \
42 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \
43 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \
44 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
45 file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \
46 file://0003-To-fix-errors-as-following.patch \
47 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \
48 file://0001-Dont-use-isystem.patch \
49 "
50PV = "4.1.0"
Brad Bishop19323692019-04-05 15:28:33 -040051
52S = "${WORKDIR}/git"
53
54do_unpack_extra() {
Brad Bishop19323692019-04-05 15:28:33 -040055 tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR}
56 cp ${WORKDIR}/vgg/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src
57 cp ${WORKDIR}/boostdesc/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src
58}
59addtask unpack_extra after do_unpack before do_patch
60
61EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
62 -DWITH_1394=OFF \
63 -DENABLE_PRECOMPILED_HEADERS=OFF \
64 -DCMAKE_SKIP_RPATH=ON \
65 -DOPENCV_ICV_HASH=${IPP_MD5} \
66 -DIPPROOT=${WORKDIR}/ippicv_lnx \
Brad Bishop868407c2019-11-04 13:24:47 -050067 -DOPENCV_GENERATE_PKGCONFIG=ON \
Brad Bishop19323692019-04-05 15:28:33 -040068 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
69 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
70 ${@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)} \
71"
72EXTRA_OECMAKE_append_x86 = " -DX86=ON"
73
74PACKAGECONFIG ??= "python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
75 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
76 ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}"
77
78PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
79PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
80PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
81PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
82PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
83PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
84PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
85PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
86PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
87PACKAGECONFIG[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,"
88PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
89PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
90PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
91PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
92PACKAGECONFIG[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,"
93PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
94PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
95PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
96PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
97PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
98PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
99PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
100PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
101
102inherit pkgconfig cmake
103
104inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
105inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
106
107export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
108export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
109export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
110export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
111export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
112
113TARGET_CC_ARCH += "-I${S}/include "
114
115PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
116 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
117 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
118 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
119 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
120 ${PN}-apps"
121
122python populate_packages_prepend () {
123 cv_libdir = d.expand('${libdir}')
124 do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
125 do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
126 do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
127 do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
128
129 pn = d.getVar('PN')
130 metapkg = pn + '-dev'
131 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
132 blacklist = [ metapkg ]
133 metapkg_rdepends = [ ]
134 packages = d.getVar('PACKAGES').split()
135 for pkg in packages[1:]:
136 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
137 metapkg_rdepends.append(pkg)
138 d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
139
140 metapkg = pn
141 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
142 blacklist = [ metapkg, "libopencv-ts" ]
143 metapkg_rdepends = [ ]
144 for pkg in packages[1:]:
145 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'):
146 metapkg_rdepends.append(pkg)
147 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
148}
149
150PACKAGES_DYNAMIC += "^libopencv-.*"
151
152FILES_${PN} = ""
153FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
Brad Bishop26bdd442019-08-16 17:08:17 -0400154FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake"
155FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a"
156FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses"
Brad Bishop19323692019-04-05 15:28:33 -0400157FILES_${PN}-java = "${datadir}/OpenCV/java"
Brad Bishop26bdd442019-08-16 17:08:17 -0400158FILES_${PN}-samples = "${datadir}/opencv4/samples/"
Brad Bishop19323692019-04-05 15:28:33 -0400159
160INSANE_SKIP_${PN}-java = "libdir"
161INSANE_SKIP_${PN}-dbg = "libdir"
162
163ALLOW_EMPTY_${PN} = "1"
164
165SUMMARY_python-opencv = "Python bindings to opencv"
166FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
167RDEPENDS_python-opencv = "python-core python-numpy"
168
169SUMMARY_python3-opencv = "Python bindings to opencv"
170FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
171RDEPENDS_python3-opencv = "python3-core python3-numpy"
172
Brad Bishopba6de432019-05-21 08:07:33 -0400173RDEPENDS_${PN}-apps = "bash"
Brad Bishop19323692019-04-05 15:28:33 -0400174
175do_install_append() {
Brad Bishop19323692019-04-05 15:28:33 -0400176 # Move Python files into correct library folder (for multilib build)
177 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
178 mv ${D}/usr/lib/* ${D}/${libdir}/
179 rm -rf ${D}/usr/lib
180 fi
181}