diff options
author | Connor Abbott <cwabbott0@gmail.com> | 2011-10-31 16:22:04 +0000 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2011-11-01 08:35:36 +0100 |
commit | 4d73a968b2cb3ac9e9defd6078942faea44da024 (patch) | |
tree | a29b1421b8c18437c4090fc40f861469b779849a | |
parent | 5dc3cb849e4d9f84a2788de9dd096f9c1a5386ea (diff) | |
download | meta-openembedded-4d73a968b2cb3ac9e9defd6078942faea44da024.tar.gz |
opencv: import from oe-classic and upgrade to 2.3.1
OpenCV <= 2.2 won't compile on oe-core due to the lack of v4l1 headers, and therefore wasn't included in this patch.
Also, the support for newer cv2-style python bindings is a bit hacked up at the moment due to the way OpenCV detects the Python version and Numpy headers (see 0001-Fix-CMakeLists.txt-numpy-detection.patch). In particular, it requires the native & target python to be the same version and have similar site-packages directories, which is true at least for now in OE.
Signed-off-by: Connor Abbott <cwabbott0@gmail.com>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
3 files changed, 153 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/opencv/opencv-samples_2.3.bb b/meta-oe/recipes-support/opencv/opencv-samples_2.3.bb new file mode 100644 index 000000000..6664b3f72 --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv-samples_2.3.bb | |||
@@ -0,0 +1,42 @@ | |||
1 | DESCRIPTION = "Opencv : The Open Computer Vision Library" | ||
2 | HOMEPAGE = "http://opencv.willowgarage.com/wiki/" | ||
3 | SECTION = "libs" | ||
4 | LICENSE = "BSD" | ||
5 | |||
6 | DEPENDS = "opencv" | ||
7 | |||
8 | LIC_FILES_CHKSUM = "file://include/opencv2/opencv.hpp;endline=41;md5=6d690d8488a6fca7a2c192932466bb14 \ | ||
9 | " | ||
10 | |||
11 | SRC_URI = "svn://code.ros.org/svn/opencv/tags/2.3.1;module=opencv;proto=https \ | ||
12 | " | ||
13 | |||
14 | SRCREV = "6923" | ||
15 | PV = "2.3.1" | ||
16 | PR = "r0" | ||
17 | |||
18 | S = "${WORKDIR}/opencv" | ||
19 | |||
20 | do_install() { | ||
21 | cd samples/c | ||
22 | install -d ${D}/${bindir} | ||
23 | install -d ${D}/${datadir}/opencv/samples | ||
24 | |||
25 | cp * ${D}/${datadir}/opencv/samples || true | ||
26 | |||
27 | for i in *.c; do | ||
28 | echo "compiling $i" | ||
29 | ${CXX} ${CFLAGS} ${LDFLAGS} -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv` || true | ||
30 | install -m 0755 `basename $i .c` ${D}/${bindir} || true | ||
31 | rm ${D}/${datadir}/opencv/samples/`basename $i .c` || true | ||
32 | done | ||
33 | for i in *.cpp; do | ||
34 | echo "compiling $i" | ||
35 | ${CXX} ${CFLAGS} ${LDFLAGS} -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv` || true | ||
36 | install -m 0755 `basename $i .cpp` ${D}/${bindir} || true | ||
37 | rm ${D}/${datadir}/opencv/samples/`basename $i .cpp` || true | ||
38 | done | ||
39 | } | ||
40 | |||
41 | FILES_${PN}-dev += "${datadir}/opencv/samples/*.c* ${datadir}/opencv/samples/*.vcp* ${datadir}/opencv/samples/build*" | ||
42 | FILES_${PN} += "${bindir} ${datadir}/opencv" | ||
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-Fix-CMakeLists.txt-numpy-detection.patch b/meta-oe/recipes-support/opencv/opencv/0001-Fix-CMakeLists.txt-numpy-detection.patch new file mode 100644 index 000000000..dba00f8a1 --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv/0001-Fix-CMakeLists.txt-numpy-detection.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From a7301911a3cdf9196abd93ff894a9e86e0bcdc5e Mon Sep 17 00:00:00 2001 | ||
2 | From: Connor Abbott <cwabbott0@gmail.com> | ||
3 | Date: Sun, 30 Oct 2011 20:00:03 -0400 | ||
4 | Subject: [PATCH] Fix CMakeLists.txt numpy detection | ||
5 | |||
6 | Right now, the code opencv uses to detect where the numpy include files are doesn't work with cross-compiling because it uses the native python to determine the environment. To make this a little better, allow the user to explictly specify the path using -DPYTHON_NUMPY_INCLUDE_DIRS=path/to/numpy/include/dir . | ||
7 | Signed-off-by: Connor Abbott <cwabbott0@gmail.com> | ||
8 | --- | ||
9 | CMakeLists.txt | 12 ++++++++---- | ||
10 | 1 files changed, 8 insertions(+), 4 deletions(-) | ||
11 | |||
12 | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
13 | index ff8f20c..8edbd78 100644 | ||
14 | --- a/CMakeLists.txt | ||
15 | +++ b/CMakeLists.txt | ||
16 | @@ -715,10 +715,14 @@ IF ("${PYTHON_VERSION_MAJOR_MINOR}" VERSION_GREATER 2.4) | ||
17 | ENDIF() | ||
18 | |||
19 | # Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy | ||
20 | -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]" | ||
21 | - RESULT_VARIABLE PYTHON_NUMPY_PROCESS | ||
22 | - OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS | ||
23 | - OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
24 | +if(NOT DEFINED PYTHON_NUMPY_INCLUDE_DIRS) | ||
25 | + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]" | ||
26 | + RESULT_VARIABLE PYTHON_NUMPY_PROCESS | ||
27 | + OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS | ||
28 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
29 | +else() | ||
30 | + set(PYTHON_NUMPY_PROCESS 0) | ||
31 | +endif() | ||
32 | |||
33 | if(PYTHON_NUMPY_PROCESS EQUAL 0) | ||
34 | set(PYTHON_USE_NUMPY 1) | ||
35 | -- | ||
36 | 1.7.4.1 | ||
37 | |||
diff --git a/meta-oe/recipes-support/opencv/opencv_2.3.bb b/meta-oe/recipes-support/opencv/opencv_2.3.bb new file mode 100644 index 000000000..76688119c --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv_2.3.bb | |||
@@ -0,0 +1,74 @@ | |||
1 | DESCRIPTION = "Opencv : The Open Computer Vision Library" | ||
2 | HOMEPAGE = "http://opencv.willowgarage.com/wiki/" | ||
3 | SECTION = "libs" | ||
4 | |||
5 | LICENSE = "BSD" | ||
6 | LIC_FILES_CHKSUM = "file://include/opencv2/opencv.hpp;endline=41;md5=6d690d8488a6fca7a2c192932466bb14" | ||
7 | |||
8 | ARM_INSTRUCTION_SET = "arm" | ||
9 | |||
10 | DEPENDS = "python-numpy ffmpeg gtk+ libtool swig swig-native python jpeg bzip2 zlib libpng tiff glib-2.0" | ||
11 | |||
12 | SRC_URI = "svn://code.ros.org/svn/opencv/tags/2.3.1;module=opencv;proto=https \ | ||
13 | file://opencv/0001-Fix-CMakeLists.txt-numpy-detection.patch \ | ||
14 | " | ||
15 | |||
16 | SRCREV = "6923" | ||
17 | |||
18 | PV = "2.3.1" | ||
19 | PR = "r0" | ||
20 | |||
21 | S = "${WORKDIR}/opencv" | ||
22 | |||
23 | EXTRA_OECMAKE = "-DPYTHON_NUMPY_INCLUDE_DIRS=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include \ | ||
24 | -DBUILD_PYTHON_SUPPORT=ON \ | ||
25 | " | ||
26 | |||
27 | inherit distutils-base pkgconfig cmake | ||
28 | |||
29 | export BUILD_SYS | ||
30 | export HOST_SYS | ||
31 | export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" | ||
32 | export PYTHON=${STAGING_BINDIR_NATIVE}/python | ||
33 | |||
34 | TARGET_CC_ARCH += "-I${S}/include " | ||
35 | |||
36 | PACKAGES += "${PN}-apps python-opencv" | ||
37 | |||
38 | python populate_packages_prepend () { | ||
39 | cv_libdir = bb.data.expand('${libdir}', d) | ||
40 | cv_libdir_dbg = bb.data.expand('${libdir}/.debug', d) | ||
41 | do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True) | ||
42 | do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') | ||
43 | do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') | ||
44 | do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True) | ||
45 | |||
46 | pn = bb.data.getVar('PN', d, 1) | ||
47 | metapkg = pn + '-dev' | ||
48 | bb.data.setVar('ALLOW_EMPTY_' + metapkg, "1", d) | ||
49 | blacklist = [ metapkg ] | ||
50 | metapkg_rdepends = [ ] | ||
51 | packages = bb.data.getVar('PACKAGES', d, 1).split() | ||
52 | for pkg in packages[1:]: | ||
53 | if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'): | ||
54 | metapkg_rdepends.append(pkg) | ||
55 | bb.data.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends), d) | ||
56 | } | ||
57 | |||
58 | FILES_${PN} = "" | ||
59 | FILES_${PN}-apps = "${bindir}/* ${datadir}/OpenCV" | ||
60 | FILES_${PN}-dbg += "${libdir}/.debug" | ||
61 | FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig" | ||
62 | FILES_${PN}-doc = "${datadir}/OpenCV/doc" | ||
63 | |||
64 | ALLOW_EMPTY_${PN} = "1" | ||
65 | |||
66 | INSANE_SKIP_python-opencv = True | ||
67 | DESCRIPTION_python-opencv = "Python bindings to opencv" | ||
68 | FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" | ||
69 | RDEPENDS_python-opencv = "python-core python-numpy" | ||
70 | |||
71 | do_install_append() { | ||
72 | cp ${S}/include/opencv/*.h ${D}${includedir}/opencv/ | ||
73 | sed -i '/blobtrack/d' ${D}${includedir}/opencv/cvaux.h | ||
74 | } | ||