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" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=6450921bb12a3133c8f5cb2a80343710" |
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 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 13 | SRCREV_opencv = "371bba8f54560b374fbcd47e7e02f015ac4969ad" |
| 14 | SRCREV_contrib = "2c32791a9c500343568a21ea34bf2daeac2adae7" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 15 | SRCREV_ipp = "32e315a5b106a7b89dbed51c28f8120a48b368b4" |
| 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): |
| 24 | return "ippicv_2019_lnx_ia32_general_20180723.tgz" |
| 25 | else: |
| 26 | return "ippicv_2019_lnx_intel64_general_20180723.tgz" |
| 27 | |
| 28 | def 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 | |
| 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 \ |
| 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 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 | 0e2770c | 2020-01-21 07:31:46 -0500 | [diff] [blame] | 51 | file://0001-carotene-Replace-ipcp-unit-growth-with-ipa-cp-unit-g.patch \ |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 52 | file://download.patch \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 53 | " |
| 54 | PV = "4.1.0" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 55 | |
| 56 | S = "${WORKDIR}/git" |
| 57 | |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 58 | # 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 |
| 60 | OPENCV_DLDIR = "${WORKDIR}/downloads" |
| 61 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 62 | do_unpack_extra() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 63 | tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR} |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 64 | |
| 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 81 | } |
| 82 | addtask unpack_extra after do_unpack before do_patch |
| 83 | |
| 84 | EXTRA_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 Bishop | 868407c | 2019-11-04 13:24:47 -0500 | [diff] [blame] | 90 | -DOPENCV_GENERATE_PKGCONFIG=ON \ |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 91 | -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ |
| 92 | -DOPENCV_ALLOW_DOWNLOADS=OFF \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 93 | ${@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 | " |
| 97 | EXTRA_OECMAKE_append_x86 = " -DX86=ON" |
| 98 | |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 99 | 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] | 100 | ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ |
| 101 | ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}" |
| 102 | |
Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 103 | 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] | 104 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," |
| 105 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," |
| 106 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," |
| 107 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," |
| 108 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," |
| 109 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," |
| 110 | PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," |
| 111 | PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," |
| 112 | PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," |
| 113 | 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," |
| 114 | PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," |
| 115 | PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," |
| 116 | PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," |
| 117 | PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," |
| 118 | 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," |
| 119 | PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," |
| 120 | PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," |
| 121 | PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," |
| 122 | PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," |
| 123 | PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," |
| 124 | PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," |
| 125 | PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," |
| 126 | PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," |
| 127 | |
| 128 | inherit pkgconfig cmake |
| 129 | |
| 130 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)} |
| 131 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} |
| 132 | |
| 133 | export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" |
| 134 | export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" |
| 135 | export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" |
| 136 | export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" |
| 137 | export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" |
| 138 | |
| 139 | TARGET_CC_ARCH += "-I${S}/include " |
| 140 | |
| 141 | PACKAGES += "${@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 | |
| 148 | python 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 | |
| 176 | PACKAGES_DYNAMIC += "^libopencv-.*" |
| 177 | |
| 178 | FILES_${PN} = "" |
| 179 | FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 180 | FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake" |
| 181 | FILES_${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a" |
| 182 | FILES_${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 183 | FILES_${PN}-java = "${datadir}/OpenCV/java" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 184 | FILES_${PN}-samples = "${datadir}/opencv4/samples/" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 185 | |
| 186 | INSANE_SKIP_${PN}-java = "libdir" |
| 187 | INSANE_SKIP_${PN}-dbg = "libdir" |
| 188 | |
| 189 | ALLOW_EMPTY_${PN} = "1" |
| 190 | |
| 191 | SUMMARY_python-opencv = "Python bindings to opencv" |
| 192 | FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 193 | RDEPENDS_python-opencv = "python-core python-numpy" |
| 194 | |
| 195 | SUMMARY_python3-opencv = "Python bindings to opencv" |
| 196 | FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 197 | RDEPENDS_python3-opencv = "python3-core python3-numpy" |
| 198 | |
Brad Bishop | ba6de43 | 2019-05-21 08:07:33 -0400 | [diff] [blame] | 199 | RDEPENDS_${PN}-apps = "bash" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 200 | |
| 201 | do_install_append() { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 202 | # 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 | } |