Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [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=2b2f8752cc5edf504d283107d033f544" |
| 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 = "87c27a074db9f6d9d60513f351daa903606ca370" |
| 14 | SRCREV_contrib = "2a9d1b22ed76eb22fad1a5edf6faf4d05f207b13" |
| 15 | SRCREV_ipp = "a62e20676a60ee0ad6581e217fe7e4bada3b95db" |
| 16 | SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" |
| 17 | SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 18 | SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59" |
| 19 | SRC_URI[tinydnn.sha256sum] = "e2c61ce8c5debaa644121179e9dbdcf83f497f39de853f8dd5175846505aa18b" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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_2017u2_lnx_ia32_20170418.tgz" |
| 26 | else: |
| 27 | return "ippicv_2017u2_lnx_intel64_20170418.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 "f2cece00d802d4dea86df52ed095257e" |
| 34 | else: |
| 35 | return "808b791a6eac9ed78d32a7666804320e" |
| 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_20170418;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 \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 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 \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 47 | file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \ |
| 48 | file://fixpkgconfig.patch \ |
| 49 | file://uselocalxfeatures.patch;patchdir=../contrib/ \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 50 | file://tinydnn.patch;patchdir=../contrib/ \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 51 | file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \ |
| 52 | file://0003-To-fix-errors-as-following.patch \ |
| 53 | file://0001-build-workaround-GCC-7.1.1-compilation-issue-with-sa.patch \ |
| 54 | file://0002-imgcodecs-refactoring-improve-code-quality.patch \ |
| 55 | file://0003-imgproc-test-add-checks-for-remove-call.patch \ |
| 56 | file://0001-Dont-use-isystem.patch \ |
| 57 | file://0001-carotene-don-t-use-__asm__-with-aarch64.patch \ |
| 58 | file://0002-Do-not-enable-asm-with-clang.patch \ |
| 59 | file://CVE-2017-14136.patch \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 60 | file://javagen.patch \ |
| 61 | file://protobuf.patch \ |
| 62 | file://already-exists.patch \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | " |
| 64 | PV = "3.3+git${SRCPV}" |
| 65 | |
| 66 | S = "${WORKDIR}/git" |
| 67 | |
| 68 | do_unpack_extra() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | mkdir -p ${S}/3rdparty/tinydnn/ |
| 70 | tar xzf ${WORKDIR}/v1.0.0a3.tar.gz -C ${S}/3rdparty/tinydnn/ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 71 | tar xzf ${WORKDIR}/ipp/ippicv/${IPP_FILENAME} -C ${WORKDIR} |
| 72 | cp ${WORKDIR}/vgg/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src |
| 73 | cp ${WORKDIR}/boostdesc/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src |
| 74 | } |
| 75 | addtask unpack_extra after do_unpack before do_patch |
| 76 | |
| 77 | EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \ |
| 78 | -DWITH_1394=OFF \ |
| 79 | -DCMAKE_SKIP_RPATH=ON \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 80 | -DOPENCV_ICV_HASH=${IPP_MD5} \ |
| 81 | -DIPPROOT=${WORKDIR}/ippicv_lnx \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 82 | ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \ |
| 83 | ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \ |
| 84 | ${@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)} \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 85 | ${@oe.utils.conditional("libdir", "/usr/lib64", "-DLIB_SUFFIX=64", "", d)} \ |
| 86 | ${@oe.utils.conditional("libdir", "/usr/lib32", "-DLIB_SUFFIX=32", "", d)} \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 87 | " |
| 88 | EXTRA_OECMAKE_append_x86 = " -DX86=ON" |
| 89 | |
| 90 | PACKAGECONFIG ??= "python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \ |
| 91 | ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ |
| 92 | ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}" |
| 93 | |
| 94 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," |
| 95 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," |
| 96 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," |
| 97 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," |
| 98 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," |
| 99 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," |
| 100 | PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," |
| 101 | PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," |
| 102 | PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," |
| 103 | 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," |
| 104 | PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," |
| 105 | PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," |
| 106 | PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," |
| 107 | PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," |
| 108 | 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," |
| 109 | PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," |
| 110 | PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," |
| 111 | PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," |
| 112 | PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," |
| 113 | PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," |
| 114 | PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," |
| 115 | PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," |
| 116 | PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," |
| 117 | |
| 118 | inherit pkgconfig cmake |
| 119 | |
| 120 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)} |
| 121 | inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} |
| 122 | |
| 123 | export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" |
| 124 | export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" |
| 125 | export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" |
| 126 | export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" |
| 127 | export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" |
| 128 | |
| 129 | TARGET_CC_ARCH += "-I${S}/include " |
| 130 | |
| 131 | PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \ |
| 132 | ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \ |
| 133 | ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \ |
| 134 | ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \ |
| 135 | ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \ |
| 136 | ${PN}-apps" |
| 137 | |
| 138 | python populate_packages_prepend () { |
| 139 | cv_libdir = d.expand('${libdir}') |
| 140 | do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True) |
| 141 | do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') |
| 142 | do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') |
| 143 | do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True) |
| 144 | |
| 145 | pn = d.getVar('PN') |
| 146 | metapkg = pn + '-dev' |
| 147 | d.setVar('ALLOW_EMPTY_' + metapkg, "1") |
| 148 | blacklist = [ metapkg ] |
| 149 | metapkg_rdepends = [ ] |
| 150 | packages = d.getVar('PACKAGES').split() |
| 151 | for pkg in packages[1:]: |
| 152 | if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'): |
| 153 | metapkg_rdepends.append(pkg) |
| 154 | d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends)) |
| 155 | |
| 156 | metapkg = pn |
| 157 | d.setVar('ALLOW_EMPTY_' + metapkg, "1") |
| 158 | blacklist = [ metapkg, "libopencv-ts" ] |
| 159 | metapkg_rdepends = [ ] |
| 160 | for pkg in packages[1:]: |
| 161 | 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'): |
| 162 | metapkg_rdepends.append(pkg) |
| 163 | d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends)) |
| 164 | } |
| 165 | |
| 166 | PACKAGES_DYNAMIC += "^libopencv-.*" |
| 167 | |
| 168 | FILES_${PN} = "" |
| 169 | FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" |
| 170 | FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${datadir}/OpenCV/*.cmake" |
| 171 | FILES_${PN}-staticdev += "${datadir}/OpenCV/3rdparty/lib/*.a" |
| 172 | FILES_${PN}-apps = "${bindir}/* ${datadir}/OpenCV" |
| 173 | FILES_${PN}-java = "${datadir}/OpenCV/java" |
| 174 | FILES_${PN}-samples = "${datadir}/OpenCV/samples/" |
| 175 | |
| 176 | INSANE_SKIP_${PN}-java = "libdir" |
| 177 | INSANE_SKIP_${PN}-dbg = "libdir" |
| 178 | |
| 179 | ALLOW_EMPTY_${PN} = "1" |
| 180 | |
| 181 | SUMMARY_python-opencv = "Python bindings to opencv" |
| 182 | FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 183 | RDEPENDS_python-opencv = "python-core python-numpy" |
| 184 | |
| 185 | SUMMARY_python3-opencv = "Python bindings to opencv" |
| 186 | FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" |
| 187 | RDEPENDS_python3-opencv = "python3-core python3-numpy" |
| 188 | |
| 189 | do_install_append() { |
| 190 | cp ${S}/include/opencv/*.h ${D}${includedir}/opencv/ |
| 191 | sed -i '/blobtrack/d' ${D}${includedir}/opencv/cvaux.h |
| 192 | |
| 193 | # Move Python files into correct library folder (for multilib build) |
| 194 | if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then |
| 195 | mv ${D}/usr/lib/* ${D}/${libdir}/ |
| 196 | rm -rf ${D}/usr/lib |
| 197 | fi |
| 198 | |
| 199 | if ${@bb.utils.contains("PACKAGECONFIG", "samples", "true", "false", d)}; then |
| 200 | install -d ${D}${datadir}/OpenCV/samples/bin/ |
| 201 | cp -f bin/*-tutorial-* bin/*-example-* ${D}${datadir}/OpenCV/samples/bin/ |
| 202 | fi |
| 203 | } |