Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | SUMMARY = "Opencv : The Open Computer Vision Library" |
| 2 | HOMEPAGE = "http://opencv.org/" |
| 3 | SECTION = "libs" |
| 4 | |
| 5 | LICENSE = "BSD-3-Clause" |
| 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=62d89c5dcb0583609ea919c56be0ee76" |
| 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 | |
| 13 | SRCREV_opencv = "b38c50b3d0c31e82294315ec44b54b7ef559ef12" |
| 14 | SRCREV_contrib = "1f6d6f06266e1ef336437ae5404bee1c65d42cda" |
| 15 | SRCREV_ipp = "bdb7bb85f34a8cb0d35e40a81f58da431aa1557a" |
| 16 | SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" |
| 17 | SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" |
| 18 | SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59" |
| 19 | SRC_URI[tinydnn.sha256sum] = "e2c61ce8c5debaa644121179e9dbdcf83f497f39de853f8dd5175846505aa18b" |
| 20 | |
| 21 | def ipp_filename(d): |
| 22 | import re |
| 23 | arch = d.getVar('TARGET_ARCH', True) |
| 24 | if re.match("i.86$", arch): |
| 25 | return "ippicv_2017u3_lnx_ia32_general_20180518.tgz" |
| 26 | else: |
| 27 | return "ippicv_2017u3_lnx_intel64_general_20180518.tgz" |
| 28 | |
| 29 | def ipp_md5sum(d): |
| 30 | import re |
| 31 | arch = d.getVar('TARGET_ARCH', True) |
| 32 | if re.match("i.86$", arch): |
| 33 | return "ea72de74dae3c604eb6348395366e78e" |
| 34 | else: |
| 35 | return "b7cc351267db2d34b9efa1cd22ff0572" |
| 36 | |
| 37 | IPP_FILENAME = "${@ipp_filename(d)}" |
| 38 | IPP_MD5 = "${@ipp_md5sum(d)}" |
| 39 | |
| 40 | SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" |
| 41 | SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \ |
| 42 | git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \ |
| 43 | git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20180518;destsuffix=ipp;name=ipp \ |
| 44 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \ |
| 45 | git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \ |
| 46 | https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz;destsuffix=git/3rdparty/tinydnn/tiny-dnn-1.0.0a3;name=tinydnn;unpack=false \ |
| 47 | file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \ |
| 48 | file://uselocalxfeatures.patch;patchdir=../contrib/ \ |
| 49 | file://0001-Add-missing-multi-line-separator.patch;patchdir=../contrib/ \ |
| 50 | file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \ |
| 51 | file://0003-To-fix-errors-as-following.patch \ |
| 52 | file://fixpkgconfig.patch \ |
| 53 | file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ |
| 54 | file://0001-Dont-use-isystem.patch \ |
| 55 | file://0001-Check-for-clang-before-using-isystem.patch \ |
| 56 | " |
| 57 | PV = "3.4.3+git${SRCPV}" |
| 58 | |
| 59 | S = "${WORKDIR}/git" |
| 60 | |
| 61 | do_unpack_extra() { |
| 62 | mkdir -p ${S}/3rdparty/tinydnn/ |
| 63 | tar xzf ${WORKDIR}/v1.0.0a3.tar.gz -C ${S}/3rdparty/tinydnn/ |
| 64 | tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR} |
| 65 | cp ${WORKDIR}/vgg/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src |
| 66 | cp ${WORKDIR}/boostdesc/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src |
| 67 | } |
| 68 | addtask unpack_extra after do_unpack before do_patch |
| 69 | |
| 70 | EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \ |
| 71 | -DWITH_1394=OFF \ |
| 72 | -DENABLE_PRECOMPILED_HEADERS=OFF \ |
| 73 | -DCMAKE_SKIP_RPATH=ON \ |
| 74 | -DOPENCV_ICV_HASH=${IPP_MD5} \ |
| 75 | -DIPPROOT=${WORKDIR}/ippicv_lnx \ |
| 76 | ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \ |
| 77 | ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \ |
| 78 | ${@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)} \ |
| 79 | ${@oe.utils.conditional("libdir", "/usr/lib64", "-DLIB_SUFFIX=64", "", d)} \ |
| 80 | ${@oe.utils.conditional("libdir", "/usr/lib32", "-DLIB_SUFFIX=32", "", d)} \ |
| 81 | " |
| 82 | EXTRA_OECMAKE_append_x86 = " -DX86=ON" |
| 83 | |
| 84 | PACKAGECONFIG ??= "python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \ |
| 85 | ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ |
| 86 | ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}" |
| 87 | |
| 88 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," |
| 89 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," |
| 90 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," |
| 91 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," |
| 92 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," |
| 93 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," |
| 94 | PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," |
| 95 | PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," |
| 96 | PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," |
| 97 | 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," |
| 98 | PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," |
| 99 | PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," |
| 100 | PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," |
| 101 | PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," |
| 102 | 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," |
| 103 | PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," |
| 104 | PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," |
| 105 | PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," |
| 106 | PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," |
| 107 | PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," |
| 108 | PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," |
| 109 | PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," |
| 110 | PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," |
| 111 | |
| 112 | inherit pkgconfig cmake |
| 113 | |
| 114 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)} |
| 115 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} |
| 116 | |
| 117 | export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" |
| 118 | export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" |
| 119 | export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" |
| 120 | export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" |
| 121 | export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" |
| 122 | |
| 123 | TARGET_CC_ARCH += "-I${S}/include " |
| 124 | |
| 125 | PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \ |
| 126 | ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \ |
| 127 | ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \ |
| 128 | ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \ |
| 129 | ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \ |
| 130 | ${PN}-apps" |
| 131 | |
| 132 | python populate_packages_prepend () { |
| 133 | cv_libdir = d.expand('${libdir}') |
| 134 | do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True) |
| 135 | do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') |
| 136 | do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') |
| 137 | do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True) |
| 138 | |
| 139 | pn = d.getVar('PN') |
| 140 | metapkg = pn + '-dev' |
| 141 | d.setVar('ALLOW_EMPTY_' + metapkg, "1") |
| 142 | blacklist = [ metapkg ] |
| 143 | metapkg_rdepends = [ ] |
| 144 | packages = d.getVar('PACKAGES').split() |
| 145 | for pkg in packages[1:]: |
| 146 | if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'): |
| 147 | metapkg_rdepends.append(pkg) |
| 148 | d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends)) |
| 149 | |
| 150 | metapkg = pn |
| 151 | d.setVar('ALLOW_EMPTY_' + metapkg, "1") |
| 152 | blacklist = [ metapkg, "libopencv-ts" ] |
| 153 | metapkg_rdepends = [ ] |
| 154 | for pkg in packages[1:]: |
| 155 | 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'): |
| 156 | metapkg_rdepends.append(pkg) |
| 157 | d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends)) |
| 158 | } |
| 159 | |
| 160 | PACKAGES_DYNAMIC += "^libopencv-.*" |
| 161 | |
| 162 | FILES_${PN} = "" |
| 163 | FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" |
| 164 | FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${datadir}/OpenCV/*.cmake" |
| 165 | FILES_${PN}-staticdev += "${datadir}/OpenCV/3rdparty/lib/*.a" |
| 166 | FILES_${PN}-apps = "${bindir}/* ${datadir}/OpenCV" |
| 167 | FILES_${PN}-java = "${datadir}/OpenCV/java" |
| 168 | FILES_${PN}-samples = "${datadir}/OpenCV/samples/" |
| 169 | |
| 170 | INSANE_SKIP_${PN}-java = "libdir" |
| 171 | INSANE_SKIP_${PN}-dbg = "libdir" |
| 172 | |
| 173 | ALLOW_EMPTY_${PN} = "1" |
| 174 | |
| 175 | SUMMARY_python-opencv = "Python bindings to opencv" |
| 176 | FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 177 | RDEPENDS_python-opencv = "python-core python-numpy" |
| 178 | |
| 179 | SUMMARY_python3-opencv = "Python bindings to opencv" |
| 180 | FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 181 | RDEPENDS_python3-opencv = "python3-core python3-numpy" |
| 182 | |
| 183 | do_install_append() { |
| 184 | cp ${S}/include/opencv/*.h ${D}${includedir}/opencv/ |
| 185 | sed -i '/blobtrack/d' ${D}${includedir}/opencv/cvaux.h |
| 186 | |
| 187 | # Move Python files into correct library folder (for multilib build) |
| 188 | if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then |
| 189 | mv ${D}/usr/lib/* ${D}/${libdir}/ |
| 190 | rm -rf ${D}/usr/lib |
| 191 | fi |
| 192 | } |