blob: ca62de7c8f35ded997c47f662ddfba49edf7e7ba [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001SUMMARY = "Opencv : The Open Computer Vision Library"
2HOMEPAGE = "http://opencv.org/"
3SECTION = "libs"
4
5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=2b2f8752cc5edf504d283107d033f544"
7
8ARM_INSTRUCTION_SET_armv4 = "arm"
9ARM_INSTRUCTION_SET_armv5 = "arm"
10
11DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp"
12
13SRCREV_opencv = "87c27a074db9f6d9d60513f351daa903606ca370"
14SRCREV_contrib = "2a9d1b22ed76eb22fad1a5edf6faf4d05f207b13"
15SRCREV_ipp = "a62e20676a60ee0ad6581e217fe7e4bada3b95db"
16SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26"
17SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
Brad Bishop316dfdd2018-06-25 12:45:53 -040018SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59"
19SRC_URI[tinydnn.sha256sum] = "e2c61ce8c5debaa644121179e9dbdcf83f497f39de853f8dd5175846505aa18b"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020
21def 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
29def 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
37IPP_FILENAME = "${@ipp_filename(d)}"
38IPP_MD5 = "${@ipp_md5sum(d)}"
39
40SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
41SRC_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 Bishop316dfdd2018-06-25 12:45:53 -040046 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 Bishopd7bf8c12018-02-25 22:55:05 -050047 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
48 file://fixpkgconfig.patch \
49 file://uselocalxfeatures.patch;patchdir=../contrib/ \
Brad Bishop316dfdd2018-06-25 12:45:53 -040050 file://tinydnn.patch;patchdir=../contrib/ \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050051 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 Bishop316dfdd2018-06-25 12:45:53 -040060 file://javagen.patch \
61 file://protobuf.patch \
62 file://already-exists.patch \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050063"
64PV = "3.3+git${SRCPV}"
65
66S = "${WORKDIR}/git"
67
68do_unpack_extra() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040069 mkdir -p ${S}/3rdparty/tinydnn/
70 tar xzf ${WORKDIR}/v1.0.0a3.tar.gz -C ${S}/3rdparty/tinydnn/
Brad Bishopd7bf8c12018-02-25 22:55:05 -050071 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}
75addtask unpack_extra after do_unpack before do_patch
76
77EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
78 -DWITH_1394=OFF \
79 -DCMAKE_SKIP_RPATH=ON \
Brad Bishop316dfdd2018-06-25 12:45:53 -040080 -DOPENCV_ICV_HASH=${IPP_MD5} \
81 -DIPPROOT=${WORKDIR}/ippicv_lnx \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050082 ${@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 Bishop316dfdd2018-06-25 12:45:53 -040085 ${@oe.utils.conditional("libdir", "/usr/lib64", "-DLIB_SUFFIX=64", "", d)} \
86 ${@oe.utils.conditional("libdir", "/usr/lib32", "-DLIB_SUFFIX=32", "", d)} \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050087"
88EXTRA_OECMAKE_append_x86 = " -DX86=ON"
89
90PACKAGECONFIG ??= "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
94PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas,"
95PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft,"
96PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DPROTOBUF_UPDATE_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native,"
97PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog,"
98PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype,"
99PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2,"
100PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base,"
101PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3,"
102PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper,"
103PACKAGECONFIG[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,"
104PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg,"
105PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav,"
106PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils,"
107PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd,"
108PACKAGECONFIG[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,"
109PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng,"
110PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy,"
111PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy,"
112PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,,"
113PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb,"
114PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract,"
115PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff,"
116PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils,"
117
118inherit pkgconfig cmake
119
120inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)}
121inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)}
122
123export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}"
124export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}"
125export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java"
126export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native"
127export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/"
128
129TARGET_CC_ARCH += "-I${S}/include "
130
131PACKAGES += "${@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
138python 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
166PACKAGES_DYNAMIC += "^libopencv-.*"
167
168FILES_${PN} = ""
169FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*"
170FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${datadir}/OpenCV/*.cmake"
171FILES_${PN}-staticdev += "${datadir}/OpenCV/3rdparty/lib/*.a"
172FILES_${PN}-apps = "${bindir}/* ${datadir}/OpenCV"
173FILES_${PN}-java = "${datadir}/OpenCV/java"
174FILES_${PN}-samples = "${datadir}/OpenCV/samples/"
175
176INSANE_SKIP_${PN}-java = "libdir"
177INSANE_SKIP_${PN}-dbg = "libdir"
178
179ALLOW_EMPTY_${PN} = "1"
180
181SUMMARY_python-opencv = "Python bindings to opencv"
182FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
183RDEPENDS_python-opencv = "python-core python-numpy"
184
185SUMMARY_python3-opencv = "Python bindings to opencv"
186FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*"
187RDEPENDS_python3-opencv = "python3-core python3-numpy"
188
189do_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}