blob: c83186de07961637ebf2d91a4832f88743cb6ca9 [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"
Andrew Geissler7f40b712020-05-15 14:09:53 -05006LIC_FILES_CHKSUM = "file://LICENSE;md5=19598330421859a6dd353a4318091ac7"
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
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050013SRCREV_opencv = "c3bb57afeaf030f10939204d48d7c2a3842f4293"
14SRCREV_contrib = "5fae4082cc493efa5cb7a7486f9e009618a5198b"
Andrew Geissler7f40b712020-05-15 14:09:53 -050015SRCREV_ipp = "a56b6ac6f030c312b2dce17430eef13aed9af274"
Brad Bishop19323692019-04-05 15:28:33 -040016SRCREV_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):
Andrew Geissler7f40b712020-05-15 14:09:53 -050024 return "ippicv_2020_lnx_ia32_20191018_general.tgz"
Brad Bishop19323692019-04-05 15:28:33 -040025 else:
Andrew Geissler7f40b712020-05-15 14:09:53 -050026 return "ippicv_2020_lnx_intel64_20191018_general.tgz"
Brad Bishop19323692019-04-05 15:28:33 -040027
28def ipp_md5sum(d):
29 import re
30 arch = d.getVar('TARGET_ARCH')
31 if re.match("i.86$", arch):
Andrew Geissler7f40b712020-05-15 14:09:53 -050032 return "ad189a940fb60eb71f291321322fe3e8"
Brad Bishop19323692019-04-05 15:28:33 -040033 else:
Andrew Geissler7f40b712020-05-15 14:09:53 -050034 return "7421de0095c7a39162ae13a6098782f9"
Brad Bishop19323692019-04-05 15:28:33 -040035
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 \
Andrew Geissler7f40b712020-05-15 14:09:53 -050042 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20191018;destsuffix=ipp;name=ipp \
Brad Bishop26bdd442019-08-16 17:08:17 -040043 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 \
Brad Bishop26bdd442019-08-16 17:08:17 -040047 file://0003-To-fix-errors-as-following.patch \
48 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \
49 file://0001-Dont-use-isystem.patch \
Brad Bishope42b3e32020-01-15 22:08:42 -050050 file://download.patch \
Andrew Geisslerc87764f2020-06-27 00:16:32 -050051 file://0001-Make-ts-module-external.patch \
Brad Bishop26bdd442019-08-16 17:08:17 -040052 "
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050053SRC_URI_append_riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=../contrib"
Brad Bishop19323692019-04-05 15:28:33 -040054
55S = "${WORKDIR}/git"
56
Brad Bishope42b3e32020-01-15 22:08:42 -050057# OpenCV wants to download more files during configure. We download these in
58# do_fetch and construct a source cache in the format it expects
59OPENCV_DLDIR = "${WORKDIR}/downloads"
60
Brad Bishop19323692019-04-05 15:28:33 -040061do_unpack_extra() {
Brad Bishop19323692019-04-05 15:28:33 -040062 tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR}
Brad Bishope42b3e32020-01-15 22:08:42 -050063
64 md5() {
65 # Return the MD5 of $1
66 echo $(md5sum $1 | cut -d' ' -f1)
67 }
68 cache() {
69 TAG=$1
70 shift
71 mkdir --parents ${OPENCV_DLDIR}/$TAG
72 for F in $*; do
73 DEST=${OPENCV_DLDIR}/$TAG/$(md5 $F)-$(basename $F)
74 test -e $DEST || ln -s $F $DEST
75 done
76 }
77 cache xfeatures2d/boostdesc ${WORKDIR}/boostdesc/*.i
78 cache xfeatures2d/vgg ${WORKDIR}/vgg/*.i
79 cache data ${WORKDIR}/face/*.dat
Brad Bishop19323692019-04-05 15:28:33 -040080}
81addtask unpack_extra after do_unpack before do_patch
82
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050083CMAKE_VERBOSE = "VERBOSE=1"
84
Brad Bishop19323692019-04-05 15:28:33 -040085EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
86 -DWITH_1394=OFF \
87 -DENABLE_PRECOMPILED_HEADERS=OFF \
88 -DCMAKE_SKIP_RPATH=ON \
89 -DOPENCV_ICV_HASH=${IPP_MD5} \
90 -DIPPROOT=${WORKDIR}/ippicv_lnx \
Brad Bishop868407c2019-11-04 13:24:47 -050091 -DOPENCV_GENERATE_PKGCONFIG=ON \
Brad Bishope42b3e32020-01-15 22:08:42 -050092 -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \
93 -DOPENCV_ALLOW_DOWNLOADS=OFF \
Brad Bishop19323692019-04-05 15:28:33 -040094 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
95 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
96 ${@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)} \
97"
98EXTRA_OECMAKE_append_x86 = " -DX86=ON"
99
Brad Bishope42b3e32020-01-15 22:08:42 -0500100PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
Brad Bishop19323692019-04-05 15:28:33 -0400101 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
102 ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}"
103
Brad Bishope42b3e32020-01-15 22:08:42 -0500104PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade"
Brad Bishop19323692019-04-05 15:28:33 -0400105PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
106PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
107PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
108PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
109PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
110PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
111PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
112PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
113PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
114PACKAGECONFIG[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,"
115PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
116PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
117PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
118PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
119PACKAGECONFIG[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,"
120PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
121PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
122PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
123PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
124PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
125PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
126PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
127PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
128
129inherit pkgconfig cmake
130
131inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
132inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
133
134export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
135export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
136export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
137export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
138export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
139
140TARGET_CC_ARCH += "-I${S}/include "
141
142PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
143 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
144 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
145 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
146 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
147 ${PN}-apps"
148
149python populate_packages_prepend () {
150 cv_libdir = d.expand('${libdir}')
151 do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
152 do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
153 do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
154 do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
155
156 pn = d.getVar('PN')
157 metapkg = pn + '-dev'
158 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
159 blacklist = [ metapkg ]
160 metapkg_rdepends = [ ]
161 packages = d.getVar('PACKAGES').split()
162 for pkg in packages[1:]:
163 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
164 metapkg_rdepends.append(pkg)
165 d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
166
167 metapkg = pn
168 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
169 blacklist = [ metapkg, "libopencv-ts" ]
170 metapkg_rdepends = [ ]
171 for pkg in packages[1:]:
172 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'):
173 metapkg_rdepends.append(pkg)
174 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
175}
176
177PACKAGES_DYNAMIC += "^libopencv-.*"
178
179FILES_${PN} = ""
180FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
Brad Bishop26bdd442019-08-16 17:08:17 -0400181FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake"
182FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a"
183FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses"
Brad Bishop19323692019-04-05 15:28:33 -0400184FILES_${PN}-java = "${datadir}/OpenCV/java"
Brad Bishop26bdd442019-08-16 17:08:17 -0400185FILES_${PN}-samples = "${datadir}/opencv4/samples/"
Brad Bishop19323692019-04-05 15:28:33 -0400186
187INSANE_SKIP_${PN}-java = "libdir"
188INSANE_SKIP_${PN}-dbg = "libdir"
189
190ALLOW_EMPTY_${PN} = "1"
191
192SUMMARY_python-opencv = "Python bindings to opencv"
193FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
194RDEPENDS_python-opencv = "python-core python-numpy"
195
196SUMMARY_python3-opencv = "Python bindings to opencv"
197FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
198RDEPENDS_python3-opencv = "python3-core python3-numpy"
199
Brad Bishopba6de432019-05-21 08:07:33 -0400200RDEPENDS_${PN}-apps = "bash"
Brad Bishop19323692019-04-05 15:28:33 -0400201
Andrew Geisslerd688a012020-09-18 13:36:00 -0500202do_compile_prepend() {
203 # remove the build host info to improve reproducibility
204 if [ -f ${WORKDIR}/build/modules/core/version_string.inc ]; then
205 sed -i "s#${WORKDIR}#/workdir#g" ${WORKDIR}/build/modules/core/version_string.inc
206 fi
207}
208
Brad Bishop19323692019-04-05 15:28:33 -0400209do_install_append() {
Brad Bishop19323692019-04-05 15:28:33 -0400210 # Move Python files into correct library folder (for multilib build)
211 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
212 mv ${D}/usr/lib/* ${D}/${libdir}/
213 rm -rf ${D}/usr/lib
214 fi
215}
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -0500216
217TOOLCHAIN = "gcc"