Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 1 | SUMMARY = "Opencv : The Open Computer Vision Library" |
| 2 | HOMEPAGE = "http://opencv.org/" |
| 3 | SECTION = "libs" |
| 4 | |
| 5 | LICENSE = "Apache-2.0" |
| 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" |
| 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 | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 13 | SRCREV_opencv = "b0dc474160e389b9c9045da5db49d03ae17c6a6b" |
| 14 | SRCREV_contrib = "7b77c355a8fdc97667b3fa1e7a0d37e4973fc868" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 15 | SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" |
| 16 | SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" |
| 17 | SRCREV_face = "8afa57abc8229d611c4937165d20e2a2d9fc5a12" |
| 18 | SRCREV_wechat-qrcode = "a8b69ccc738421293254aec5ddb38bd523503252" |
| 19 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 20 | |
| 21 | SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" |
| 22 | SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=master;protocol=https \ |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 23 | git://github.com/opencv/opencv_contrib.git;destsuffix=git/contrib;name=contrib;branch=master;protocol=https \ |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 24 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=git/boostdesc;name=boostdesc;protocol=https \ |
| 25 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=git/vgg;name=vgg;protocol=https \ |
| 26 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_face_alignment_20170818;destsuffix=git/face;name=face;protocol=https \ |
| 27 | git://github.com/WeChatCV/opencv_3rdparty.git;branch=wechat_qrcode;destsuffix=git/wechat_qrcode;name=wechat-qrcode;protocol=https \ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 28 | file://0003-To-fix-errors-as-following.patch \ |
| 29 | file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ |
| 30 | file://0001-Dont-use-isystem.patch \ |
| 31 | file://download.patch \ |
| 32 | file://0001-Make-ts-module-external.patch \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 33 | file://0001-Add-missing-header-for-LIBAVCODEC_VERSION_INT.patch \ |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 34 | file://0008-Do-not-embed-build-directory-in-binaries.patch \ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 35 | " |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 36 | SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 37 | |
| 38 | S = "${WORKDIR}/git" |
| 39 | |
| 40 | # OpenCV wants to download more files during configure. We download these in |
| 41 | # do_fetch and construct a source cache in the format it expects |
| 42 | OPENCV_DLDIR = "${WORKDIR}/downloads" |
| 43 | |
| 44 | do_unpack_extra() { |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 45 | |
| 46 | md5() { |
| 47 | # Return the MD5 of $1 |
| 48 | echo $(md5sum $1 | cut -d' ' -f1) |
| 49 | } |
| 50 | cache() { |
| 51 | TAG=$1 |
| 52 | shift |
| 53 | mkdir --parents ${OPENCV_DLDIR}/$TAG |
| 54 | for F in $*; do |
| 55 | DEST=${OPENCV_DLDIR}/$TAG/$(md5 $F)-$(basename $F) |
| 56 | test -e $DEST || ln -s $F $DEST |
| 57 | done |
| 58 | } |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 59 | cache xfeatures2d/boostdesc ${S}/boostdesc/*.i |
| 60 | cache xfeatures2d/vgg ${S}/vgg/*.i |
| 61 | cache data ${S}/face/*.dat |
| 62 | cache wechat_qrcode ${S}/wechat_qrcode/*.caffemodel |
| 63 | cache wechat_qrcode ${S}/wechat_qrcode/*.prototxt |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 64 | } |
| 65 | addtask unpack_extra after do_unpack before do_patch |
| 66 | |
| 67 | CMAKE_VERBOSE = "VERBOSE=1" |
| 68 | |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 69 | EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${S}/contrib/modules \ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 70 | -DWITH_1394=OFF \ |
| 71 | -DENABLE_PRECOMPILED_HEADERS=OFF \ |
| 72 | -DCMAKE_SKIP_RPATH=ON \ |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 73 | -DWITH_IPP=OFF \ |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 74 | -DOPENCV_GENERATE_PKGCONFIG=ON \ |
| 75 | -DOPENCV_DOWNLOAD_PATH=${OPENCV_DLDIR} \ |
| 76 | -DOPENCV_ALLOW_DOWNLOADS=OFF \ |
| 77 | ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \ |
| 78 | ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \ |
| 79 | ${@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)} \ |
| 80 | " |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 81 | LDFLAGS:append:mips = " -Wl,--no-as-needed -latomic -Wl,--as-needed" |
| 82 | LDFLAGS:append:riscv32 = " -Wl,--no-as-needed -latomic -Wl,--as-needed" |
| 83 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 84 | EXTRA_OECMAKE:append:x86 = " -DX86=ON" |
| 85 | # disable sse4.1 and sse4.2 to fix 32bit build failure |
| 86 | # https://github.com/opencv/opencv/issues/21597 |
| 87 | EXTRA_OECMAKE:remove:x86 = " -DENABLE_SSE41=1 -DENABLE_SSE42=1" |
| 88 | |
| 89 | PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \ |
| 90 | ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 91 | ${@bb.utils.contains_any("LICENSE_FLAGS_ACCEPTED", "commercial_ffmpeg commercial", "libav", "", d)}" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 92 | |
| 93 | # TBB does not build for powerpc so disable that package config |
| 94 | PACKAGECONFIG:remove:powerpc = "tbb" |
| 95 | # tbb now needs getcontect/setcontext which is not there for all arches on musl |
| 96 | PACKAGECONFIG:remove:libc-musl:riscv64 = "tbb" |
| 97 | PACKAGECONFIG:remove:libc-musl:riscv32 = "tbb" |
| 98 | |
| 99 | PACKAGECONFIG[gapi] = "-DWITH_ADE=ON -Dade_DIR=${STAGING_LIBDIR},-DWITH_ADE=OFF,ade" |
| 100 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," |
| 101 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," |
| 102 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," |
| 103 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," |
| 104 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," |
| 105 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," |
| 106 | PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," |
| 107 | PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," |
| 108 | PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," |
| 109 | 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," |
| 110 | PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," |
| 111 | PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," |
| 112 | PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," |
| 113 | PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," |
| 114 | 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," |
| 115 | PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," |
| 116 | PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," |
| 117 | PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," |
| 118 | PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," |
| 119 | PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," |
| 120 | PACKAGECONFIG[tests] = "-DBUILD_TESTS=ON,-DBUILD_TESTS=OFF,," |
| 121 | PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," |
| 122 | PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," |
| 123 | PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," |
| 124 | |
| 125 | inherit pkgconfig cmake |
| 126 | |
| 127 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'setuptools3-base', '', d)} |
| 128 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} |
| 129 | |
| 130 | export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" |
| 131 | export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" |
| 132 | export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" |
| 133 | export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" |
| 134 | export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" |
| 135 | |
| 136 | TARGET_CC_ARCH += "-I${S}/include " |
| 137 | |
| 138 | PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \ |
| 139 | ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \ |
| 140 | ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \ |
| 141 | ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \ |
| 142 | ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \ |
| 143 | ${PN}-apps" |
| 144 | |
| 145 | python populate_packages:prepend () { |
| 146 | cv_libdir = d.expand('${libdir}') |
| 147 | do_split_packages(d, cv_libdir, r'^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True) |
| 148 | do_split_packages(d, cv_libdir, r'^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') |
| 149 | do_split_packages(d, cv_libdir, r'^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') |
| 150 | do_split_packages(d, cv_libdir, r'^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True) |
| 151 | |
| 152 | pn = d.getVar('PN') |
| 153 | metapkg = pn + '-dev' |
| 154 | d.setVar('ALLOW_EMPTY:' + metapkg, "1") |
| 155 | blacklist = [ metapkg ] |
| 156 | metapkg_rdepends = [ ] |
| 157 | packages = d.getVar('PACKAGES').split() |
| 158 | for pkg in packages[1:]: |
| 159 | if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'): |
| 160 | metapkg_rdepends.append(pkg) |
| 161 | d.setVar('RRECOMMENDS:' + metapkg, ' '.join(metapkg_rdepends)) |
| 162 | |
| 163 | metapkg = pn |
| 164 | d.setVar('ALLOW_EMPTY:' + metapkg, "1") |
| 165 | blacklist = [ metapkg, "libopencv-ts" ] |
| 166 | metapkg_rdepends = [ ] |
| 167 | for pkg in packages[1:]: |
| 168 | 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'): |
| 169 | metapkg_rdepends.append(pkg) |
| 170 | d.setVar('RDEPENDS:' + metapkg, ' '.join(metapkg_rdepends)) |
| 171 | } |
| 172 | |
| 173 | PACKAGES_DYNAMIC += "^libopencv-.*" |
| 174 | |
| 175 | FILES:${PN} = "" |
| 176 | FILES:${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" |
| 177 | FILES:${PN}-dev = "${includedir} ${libdir}/pkgconfig ${libdir}/cmake/opencv4/*.cmake" |
| 178 | FILES:${PN}-staticdev += "${libdir}/opencv4/3rdparty/*.a" |
| 179 | FILES:${PN}-apps = "${bindir}/* ${datadir}/opencv4 ${datadir}/licenses" |
| 180 | FILES:${PN}-java = "${datadir}/OpenCV/java" |
| 181 | FILES:${PN}-samples = "${datadir}/opencv4/samples/" |
| 182 | |
| 183 | INSANE_SKIP:${PN}-java = "libdir" |
| 184 | INSANE_SKIP:${PN}-dbg = "libdir" |
| 185 | |
| 186 | ALLOW_EMPTY:${PN} = "1" |
| 187 | |
| 188 | SUMMARY:python-opencv = "Python bindings to opencv" |
| 189 | FILES:python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 190 | RDEPENDS:python-opencv = "python-core python-numpy" |
| 191 | |
| 192 | SUMMARY:python3-opencv = "Python bindings to opencv" |
| 193 | FILES:python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 194 | RDEPENDS:python3-opencv = "python3-core python3-numpy" |
| 195 | |
| 196 | RDEPENDS:${PN}-apps = "bash" |
| 197 | |
| 198 | do_compile:prepend() { |
| 199 | # remove the build host info to improve reproducibility |
| 200 | if [ -f ${WORKDIR}/build/modules/core/version_string.inc ]; then |
| 201 | sed -i "s#${WORKDIR}#/workdir#g" ${WORKDIR}/build/modules/core/version_string.inc |
| 202 | fi |
| 203 | } |
| 204 | |
| 205 | do_install:append() { |
| 206 | # Move Python files into correct library folder (for multilib build) |
| 207 | if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then |
| 208 | mv ${D}/usr/lib/* ${D}/${libdir}/ |
| 209 | rm -rf ${D}/usr/lib |
| 210 | fi |
| 211 | # remove build host path to improve reproducibility |
| 212 | if [ -f ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake ]; then |
| 213 | sed -e 's@${STAGING_DIR_HOST}@@g' \ |
| 214 | -i ${D}${libdir}/cmake/opencv4/OpenCVModules.cmake |
| 215 | fi |
| 216 | # remove setup_vars_opencv4.sh as its content is confusing and useless |
| 217 | if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then |
| 218 | rm -rf ${D}${bindir}/setup_vars_opencv4.sh |
| 219 | fi |
| 220 | } |