Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | SUMMARY = "Opencv : The Open Computer Vision Library" |
| 2 | HOMEPAGE = "http://opencv.org/" |
| 3 | SECTION = "libs" |
| 4 | |
| 5 | LICENSE = "BSD-3-Clause" |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=19598330421859a6dd353a4318091ac7" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7 | |
| 8 | ARM_INSTRUCTION_SET_armv4 = "arm" |
| 9 | ARM_INSTRUCTION_SET_armv5 = "arm" |
| 10 | |
| 11 | DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp" |
| 12 | |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 13 | SRCREV_opencv = "01b2c5a77ca6dbef3baef24ebc0a5984579231d9" |
| 14 | SRCREV_contrib = "e6f32c6a69043456a806a4e802ee3ce7b7059c93" |
| 15 | SRCREV_ipp = "a56b6ac6f030c312b2dce17430eef13aed9af274" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 16 | SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" |
| 17 | SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 18 | SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | |
| 20 | def ipp_filename(d): |
| 21 | import re |
| 22 | arch = d.getVar('TARGET_ARCH') |
| 23 | if re.match("i.86$", arch): |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 24 | return "ippicv_2020_lnx_ia32_20191018_general.tgz" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 25 | else: |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 26 | return "ippicv_2020_lnx_intel64_20191018_general.tgz" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 27 | |
| 28 | def ipp_md5sum(d): |
| 29 | import re |
| 30 | arch = d.getVar('TARGET_ARCH') |
| 31 | if re.match("i.86$", arch): |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 32 | return "ad189a940fb60eb71f291321322fe3e8" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 33 | else: |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 34 | return "7421de0095c7a39162ae13a6098782f9" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | |
| 36 | IPP_FILENAME = "${@ipp_filename(d)}" |
| 37 | IPP_MD5 = "${@ipp_md5sum(d)}" |
| 38 | |
| 39 | SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" |
| 40 | SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 41 | git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \ |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 42 | git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20191018;destsuffix=ipp;name=ipp \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 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 Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 45 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=face;name=face \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 46 | 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 Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 51 | file://download.patch \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 52 | " |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 53 | PV = "4.3.0" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 54 | |
| 55 | S = "${WORKDIR}/git" |
| 56 | |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 57 | # 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 |
| 59 | OPENCV_DLDIR = "${WORKDIR}/downloads" |
| 60 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 61 | do_unpack_extra() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 62 | tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR} |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 63 | |
| 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 80 | } |
| 81 | addtask unpack_extra after do_unpack before do_patch |
| 82 | |
| 83 | EXTRA_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 Bishop | 868407c | 2019-11-04 13:24:47 -0500 | [diff] [blame] | 89 | -DOPENCV_GENERATE_PKGCONFIG=ON \ |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 90 | -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ |
| 91 | -DOPENCV_ALLOW_DOWNLOADS=OFF \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 92 | ${@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 | " |
| 96 | EXTRA_OECMAKE_append_x86 = " -DX86=ON" |
| 97 | |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 98 | PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 99 | ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ |
| 100 | ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}" |
| 101 | |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 102 | PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 103 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," |
| 104 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," |
| 105 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," |
| 106 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," |
| 107 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," |
| 108 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," |
| 109 | PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," |
| 110 | PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," |
| 111 | PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," |
| 112 | PACKAGECONFIG[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," |
| 113 | PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," |
| 114 | PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," |
| 115 | PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," |
| 116 | PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," |
| 117 | PACKAGECONFIG[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," |
| 118 | PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," |
| 119 | PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," |
| 120 | PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," |
| 121 | PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," |
| 122 | PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," |
| 123 | PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," |
| 124 | PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," |
| 125 | PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," |
| 126 | |
| 127 | inherit pkgconfig cmake |
| 128 | |
| 129 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)} |
| 130 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} |
| 131 | |
| 132 | export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" |
| 133 | export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" |
| 134 | export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" |
| 135 | export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" |
| 136 | export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" |
| 137 | |
| 138 | TARGET_CC_ARCH += "-I${S}/include " |
| 139 | |
| 140 | PACKAGES += "${@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 | |
| 147 | python 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 | |
| 175 | PACKAGES_DYNAMIC += "^libopencv-.*" |
| 176 | |
| 177 | FILES_${PN} = "" |
| 178 | FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 179 | FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake" |
| 180 | FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a" |
| 181 | FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 182 | FILES_${PN}-java = "${datadir}/OpenCV/java" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 183 | FILES_${PN}-samples = "${datadir}/opencv4/samples/" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 184 | |
| 185 | INSANE_SKIP_${PN}-java = "libdir" |
| 186 | INSANE_SKIP_${PN}-dbg = "libdir" |
| 187 | |
| 188 | ALLOW_EMPTY_${PN} = "1" |
| 189 | |
| 190 | SUMMARY_python-opencv = "Python bindings to opencv" |
| 191 | FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 192 | RDEPENDS_python-opencv = "python-core python-numpy" |
| 193 | |
| 194 | SUMMARY_python3-opencv = "Python bindings to opencv" |
| 195 | FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 196 | RDEPENDS_python3-opencv = "python3-core python3-numpy" |
| 197 | |
Brad Bishop | ba6de43 | 2019-05-21 08:07:33 -0400 | [diff] [blame] | 198 | RDEPENDS_${PN}-apps = "bash" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 199 | |
| 200 | do_install_append() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 201 | # 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 | } |