blob: 2587b189cc16c7990a68dc6f617fe8ef905487ed [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 Geissler7f40b712020-05-15 14:09:53 -050013SRCREV_opencv = "01b2c5a77ca6dbef3baef24ebc0a5984579231d9"
14SRCREV_contrib = "e6f32c6a69043456a806a4e802ee3ce7b7059c93"
15SRCREV_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 \
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 Bishope42b3e32020-01-15 22:08:42 -050051 file://download.patch \
Brad Bishop26bdd442019-08-16 17:08:17 -040052 "
Andrew Geissler7f40b712020-05-15 14:09:53 -050053PV = "4.3.0"
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
83EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
84 -DWITH_1394=OFF \
85 -DENABLE_PRECOMPILED_HEADERS=OFF \
86 -DCMAKE_SKIP_RPATH=ON \
87 -DOPENCV_ICV_HASH=${IPP_MD5} \
88 -DIPPROOT=${WORKDIR}/ippicv_lnx \
Brad Bishop868407c2019-11-04 13:24:47 -050089 -DOPENCV_GENERATE_PKGCONFIG=ON \
Brad Bishope42b3e32020-01-15 22:08:42 -050090 -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \
91 -DOPENCV_ALLOW_DOWNLOADS=OFF \
Brad Bishop19323692019-04-05 15:28:33 -040092 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \
93 ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \
94 ${@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)} \
95"
96EXTRA_OECMAKE_append_x86 = " -DX86=ON"
97
Brad Bishope42b3e32020-01-15 22:08:42 -050098PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \
Brad Bishop19323692019-04-05 15:28:33 -040099 ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \
100 ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}"
101
Brad Bishope42b3e32020-01-15 22:08:42 -0500102PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade"
Brad Bishop19323692019-04-05 15:28:33 -0400103PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
104PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
105PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
106PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
107PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
108PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
109PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
110PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
111PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
112PACKAGECONFIG[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,"
113PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
114PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
115PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
116PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
117PACKAGECONFIG[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,"
118PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
119PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
120PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
121PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
122PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
123PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
124PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
125PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
126
127inherit pkgconfig cmake
128
129inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
130inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
131
132export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
133export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
134export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
135export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
136export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
137
138TARGET_CC_ARCH += "-I${S}/include "
139
140PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \
141 ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \
142 ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \
143 ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \
144 ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \
145 ${PN}-apps"
146
147python populate_packages_prepend () {
148 cv_libdir = d.expand('${libdir}')
149 do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True)
150 do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
151 do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev')
152 do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True)
153
154 pn = d.getVar('PN')
155 metapkg = pn + '-dev'
156 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
157 blacklist = [ metapkg ]
158 metapkg_rdepends = [ ]
159 packages = d.getVar('PACKAGES').split()
160 for pkg in packages[1:]:
161 if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'):
162 metapkg_rdepends.append(pkg)
163 d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends))
164
165 metapkg = pn
166 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
167 blacklist = [ metapkg, "libopencv-ts" ]
168 metapkg_rdepends = [ ]
169 for pkg in packages[1:]:
170 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'):
171 metapkg_rdepends.append(pkg)
172 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
173}
174
175PACKAGES_DYNAMIC += "^libopencv-.*"
176
177FILES_${PN} = ""
178FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
Brad Bishop26bdd442019-08-16 17:08:17 -0400179FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake"
180FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a"
181FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses"
Brad Bishop19323692019-04-05 15:28:33 -0400182FILES_${PN}-java = "${datadir}/OpenCV/java"
Brad Bishop26bdd442019-08-16 17:08:17 -0400183FILES_${PN}-samples = "${datadir}/opencv4/samples/"
Brad Bishop19323692019-04-05 15:28:33 -0400184
185INSANE_SKIP_${PN}-java = "libdir"
186INSANE_SKIP_${PN}-dbg = "libdir"
187
188ALLOW_EMPTY_${PN} = "1"
189
190SUMMARY_python-opencv = "Python bindings to opencv"
191FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
192RDEPENDS_python-opencv = "python-core python-numpy"
193
194SUMMARY_python3-opencv = "Python bindings to opencv"
195FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
196RDEPENDS_python3-opencv = "python3-core python3-numpy"
197
Brad Bishopba6de432019-05-21 08:07:33 -0400198RDEPENDS_${PN}-apps = "bash"
Brad Bishop19323692019-04-05 15:28:33 -0400199
200do_install_append() {
Brad Bishop19323692019-04-05 15:28:33 -0400201 # Move Python files into correct library folder (for multilib build)
202 if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then
203 mv ${D}/usr/lib/* ${D}/${libdir}/
204 rm -rf ${D}/usr/lib
205 fi
206}