blob: b223334a583b462b9fc8b6fed3b18de0cdeb0f23 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001SUMMARY = "Opencv : The Open Computer Vision Library"
2HOMEPAGE = "http://opencv.org/"
3SECTION = "libs"
4
Andrew Geissler4b7c1152020-11-30 19:55:29 -06005LICENSE = "Apache-2.0"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
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 Geissler4b7c1152020-11-30 19:55:29 -060013SRCREV_opencv = "d5fd2f0155ffad366f9ac912dfd6d189a7a6a98e"
14SRCREV_contrib = "37315babf9984a5b6aa981644a20dd8df1a5ff02"
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 \
Andrew Geissler4b7c1152020-11-30 19:55:29 -060052 file://0001-samples-cmake-digits-needs-opencv_dnn-module-to-buil.patch \
Brad Bishop26bdd442019-08-16 17:08:17 -040053 "
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050054SRC_URI_append_riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=../contrib"
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
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050084CMAKE_VERBOSE = "VERBOSE=1"
85
Brad Bishop19323692019-04-05 15:28:33 -040086EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
87 -DWITH_1394=OFF \
88 -DENABLE_PRECOMPILED_HEADERS=OFF \
89 -DCMAKE_SKIP_RPATH=ON \
90 -DOPENCV_ICV_HASH=${IPP_MD5} \
91 -DIPPROOT=${WORKDIR}/ippicv_lnx \
Brad Bishop868407c2019-11-04 13:24:47 -050092 -DOPENCV_GENERATE_PKGCONFIG=ON \
Brad Bishope42b3e32020-01-15 22:08:42 -050093 -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \
94 -DOPENCV_ALLOW_DOWNLOADS=OFF \
Brad Bishop19323692019-04-05 15:28:33 -040095 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
96 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
97 ${@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)} \
98"
99EXTRA_OECMAKE_append_x86 = " -DX86=ON"
100
Brad Bishope42b3e32020-01-15 22:08:42 -0500101PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
Brad Bishop19323692019-04-05 15:28:33 -0400102 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
103 ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}"
104
Brad Bishope42b3e32020-01-15 22:08:42 -0500105PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade"
Brad Bishop19323692019-04-05 15:28:33 -0400106PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
107PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
108PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
109PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
110PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
111PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
112PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
113PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
114PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
115PACKAGECONFIG[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,"
116PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
117PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
118PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
119PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
120PACKAGECONFIG[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,"
121PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
122PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
123PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
124PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
125PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
126PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
127PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
128PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
129
130inherit pkgconfig cmake
131
132inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
133inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
134
135export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
136export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
137export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
138export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
139export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
140
141TARGET_CC_ARCH += "-I${S}/include "
142
143PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
144 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
145 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
146 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
147 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
148 ${PN}-apps"
149
150python populate_packages_prepend () {
151 cv_libdir = d.expand('${libdir}')
152 do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
153 do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
154 do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
155 do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
156
157 pn = d.getVar('PN')
158 metapkg = pn + '-dev'
159 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
160 blacklist = [ metapkg ]
161 metapkg_rdepends = [ ]
162 packages = d.getVar('PACKAGES').split()
163 for pkg in packages[1:]:
164 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
165 metapkg_rdepends.append(pkg)
166 d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
167
168 metapkg = pn
169 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
170 blacklist = [ metapkg, "libopencv-ts" ]
171 metapkg_rdepends = [ ]
172 for pkg in packages[1:]:
173 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'):
174 metapkg_rdepends.append(pkg)
175 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
176}
177
178PACKAGES_DYNAMIC += "^libopencv-.*"
179
180FILES_${PN} = ""
181FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
Brad Bishop26bdd442019-08-16 17:08:17 -0400182FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake"
183FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a"
184FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses"
Brad Bishop19323692019-04-05 15:28:33 -0400185FILES_${PN}-java = "${datadir}/OpenCV/java"
Brad Bishop26bdd442019-08-16 17:08:17 -0400186FILES_${PN}-samples = "${datadir}/opencv4/samples/"
Brad Bishop19323692019-04-05 15:28:33 -0400187
188INSANE_SKIP_${PN}-java = "libdir"
189INSANE_SKIP_${PN}-dbg = "libdir"
190
191ALLOW_EMPTY_${PN} = "1"
192
193SUMMARY_python-opencv = "Python bindings to opencv"
194FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
195RDEPENDS_python-opencv = "python-core python-numpy"
196
197SUMMARY_python3-opencv = "Python bindings to opencv"
198FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
199RDEPENDS_python3-opencv = "python3-core python3-numpy"
200
Brad Bishopba6de432019-05-21 08:07:33 -0400201RDEPENDS_${PN}-apps = "bash"
Brad Bishop19323692019-04-05 15:28:33 -0400202
Andrew Geisslerd688a012020-09-18 13:36:00 -0500203do_compile_prepend() {
204 # remove the build host info to improve reproducibility
205 if [ -f ${WORKDIR}/build/modules/core/version_string.inc ]; then
206 sed -i "s#${WORKDIR}#/workdir#g" ${WORKDIR}/build/modules/core/version_string.inc
207 fi
208}
209
Brad Bishop19323692019-04-05 15:28:33 -0400210do_install_append() {
Brad Bishop19323692019-04-05 15:28:33 -0400211 # Move Python files into correct library folder (for multilib build)
212 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
213 mv ${D}/usr/lib/* ${D}/${libdir}/
214 rm -rf ${D}/usr/lib
215 fi
216}
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -0500217
218TOOLCHAIN = "gcc"