blob: d781da600584aa30cdf1d1faf475bd7d5a7a04a5 [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 Bishope42b3e32020-01-15 22:08:42 -050018SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12"
Brad Bishop19323692019-04-05 15:28:33 -040019
20def ipp_filename(d):
21 import re
22 arch = d.getVar('TARGET_ARCH')
23 if re.match("i.86$", arch):
24 return "ippicv_2019_lnx_ia32_general_20180723.tgz"
25 else:
26 return "ippicv_2019_lnx_intel64_general_20180723.tgz"
27
28def ipp_md5sum(d):
29 import re
30 arch = d.getVar('TARGET_ARCH')
31 if re.match("i.86$", arch):
32 return "4f38432c30bfd6423164b7a24bbc98a0"
33 else:
34 return "c0bd78adb4156bbf552c1dfe90599607"
35
36IPP_FILENAME = "${@ipp_filename(d)}"
37IPP_MD5 = "${@ipp_md5sum(d)}"
38
39SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
40SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
Brad Bishop26bdd442019-08-16 17:08:17 -040041 git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \
42 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20180723;destsuffix=ipp;name=ipp \
43 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \
44 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \
Brad Bishope42b3e32020-01-15 22:08:42 -050045 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=face;name=face \
Brad Bishop26bdd442019-08-16 17:08:17 -040046 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
47 file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \
48 file://0003-To-fix-errors-as-following.patch \
49 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \
50 file://0001-Dont-use-isystem.patch \
Brad Bishop0e2770c2020-01-21 07:31:46 -050051 file://0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch \
Brad Bishope42b3e32020-01-15 22:08:42 -050052 file://download.patch \
Brad Bishop26bdd442019-08-16 17:08:17 -040053 "
54PV = "4.1.0"
Brad Bishop19323692019-04-05 15:28:33 -040055
56S = "${WORKDIR}/git"
57
Brad Bishope42b3e32020-01-15 22:08:42 -050058# OpenCV wants to download more files during configure. We download these in
59# do_fetch and construct a source cache in the format it expects
60OPENCV_DLDIR = "${WORKDIR}/downloads"
61
Brad Bishop19323692019-04-05 15:28:33 -040062do_unpack_extra() {
Brad Bishop19323692019-04-05 15:28:33 -040063 tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR}
Brad Bishope42b3e32020-01-15 22:08:42 -050064
65 md5() {
66 # Return the MD5 of $1
67 echo $(md5sum $1 | cut -d' ' -f1)
68 }
69 cache() {
70 TAG=$1
71 shift
72 mkdir --parents ${OPENCV_DLDIR}/$TAG
73 for F in $*; do
74 DEST=${OPENCV_DLDIR}/$TAG/$(md5 $F)-$(basename $F)
75 test -e $DEST || ln -s $F $DEST
76 done
77 }
78 cache xfeatures2d/boostdesc ${WORKDIR}/boostdesc/*.i
79 cache xfeatures2d/vgg ${WORKDIR}/vgg/*.i
80 cache data ${WORKDIR}/face/*.dat
Brad Bishop19323692019-04-05 15:28:33 -040081}
82addtask unpack_extra after do_unpack before do_patch
83
84EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
85 -DWITH_1394=OFF \
86 -DENABLE_PRECOMPILED_HEADERS=OFF \
87 -DCMAKE_SKIP_RPATH=ON \
88 -DOPENCV_ICV_HASH=${IPP_MD5} \
89 -DIPPROOT=${WORKDIR}/ippicv_lnx \
Brad Bishop868407c2019-11-04 13:24:47 -050090 -DOPENCV_GENERATE_PKGCONFIG=ON \
Brad Bishope42b3e32020-01-15 22:08:42 -050091 -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \
92 -DOPENCV_ALLOW_DOWNLOADS=OFF \
Brad Bishop19323692019-04-05 15:28:33 -040093 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
94 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
95 ${@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)} \
96"
97EXTRA_OECMAKE_append_x86 = " -DX86=ON"
98
Brad Bishope42b3e32020-01-15 22:08:42 -050099PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
Brad Bishop19323692019-04-05 15:28:33 -0400100 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
101 ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}"
102
Brad Bishope42b3e32020-01-15 22:08:42 -0500103PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade"
Brad Bishop19323692019-04-05 15:28:33 -0400104PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
105PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
106PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
107PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
108PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
109PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
110PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
111PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
112PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
113PACKAGECONFIG[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,"
114PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
115PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
116PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
117PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
118PACKAGECONFIG[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,"
119PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
120PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
121PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
122PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
123PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
124PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
125PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
126PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
127
128inherit pkgconfig cmake
129
130inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
131inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
132
133export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
134export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
135export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
136export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
137export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
138
139TARGET_CC_ARCH += "-I${S}/include "
140
141PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
142 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
143 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
144 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
145 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
146 ${PN}-apps"
147
148python populate_packages_prepend () {
149 cv_libdir = d.expand('${libdir}')
150 do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
151 do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
152 do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
153 do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
154
155 pn = d.getVar('PN')
156 metapkg = pn + '-dev'
157 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
158 blacklist = [ metapkg ]
159 metapkg_rdepends = [ ]
160 packages = d.getVar('PACKAGES').split()
161 for pkg in packages[1:]:
162 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
163 metapkg_rdepends.append(pkg)
164 d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
165
166 metapkg = pn
167 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
168 blacklist = [ metapkg, "libopencv-ts" ]
169 metapkg_rdepends = [ ]
170 for pkg in packages[1:]:
171 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'):
172 metapkg_rdepends.append(pkg)
173 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
174}
175
176PACKAGES_DYNAMIC += "^libopencv-.*"
177
178FILES_${PN} = ""
179FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
Brad Bishop26bdd442019-08-16 17:08:17 -0400180FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake"
181FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a"
182FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses"
Brad Bishop19323692019-04-05 15:28:33 -0400183FILES_${PN}-java = "${datadir}/OpenCV/java"
Brad Bishop26bdd442019-08-16 17:08:17 -0400184FILES_${PN}-samples = "${datadir}/opencv4/samples/"
Brad Bishop19323692019-04-05 15:28:33 -0400185
186INSANE_SKIP_${PN}-java = "libdir"
187INSANE_SKIP_${PN}-dbg = "libdir"
188
189ALLOW_EMPTY_${PN} = "1"
190
191SUMMARY_python-opencv = "Python bindings to opencv"
192FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
193RDEPENDS_python-opencv = "python-core python-numpy"
194
195SUMMARY_python3-opencv = "Python bindings to opencv"
196FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
197RDEPENDS_python3-opencv = "python3-core python3-numpy"
198
Brad Bishopba6de432019-05-21 08:07:33 -0400199RDEPENDS_${PN}-apps = "bash"
Brad Bishop19323692019-04-05 15:28:33 -0400200
201do_install_append() {
Brad Bishop19323692019-04-05 15:28:33 -0400202 # Move Python files into correct library folder (for multilib build)
203 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
204 mv ${D}/usr/lib/* ${D}/${libdir}/
205 rm -rf ${D}/usr/lib
206 fi
207}