Skip to contentSkip to conversation

OpenCV improvement

PATCH New Samuel Martin 1 participant 10 messages Oct 6, 2014

lore
Share & tools
lore
#0 lore raw

v4 cover OpenCV improvement

Hi all,

Here is a couple of improvement in OpenCV package and its reverse dependencies.

Cheers,

Samuel Martin (9):
package/opencv: update opencv options after last version bump package/opencv: add Qt5 support
package/opencv: add python/numpy support
package/opencv: add Gstreamer-1 support
package/opencv: define modules inter-dependencies package/opencv: add hidden symbol
BR2_PACKAGE_OPENCV_USE_DEPRECATED_HEADERS
package/opencv: fix opencv.pc file generation
package/vlc: add opencv support package/gstreamer1/gst1-plugins-bad: rework opencv plugin dependencies

 package/gstreamer1/gst1-plugins-bad/Config.in      |  10 +-
 package/opencv/Config.in                           | 164 +++++++++++++++++----
 ...VGenPkgconfig.cmake-rework-opencv.pc-gene.patch | 156 ++++++++++++++++++++
 ...0002-cmake-fix-gstreamer-check-conditions.patch |  78 ++++++++++
 package/opencv/opencv.mk                           |  39 ++++-
 package/vlc/Config.in                              |   1 +
 package/vlc/vlc.mk                                 |   7 +
 7 files changed, 410 insertions(+), 45 deletions(-)
 create mode 100644 package/opencv/opencv-0001-cmake-OpenCVGenPkgconfig.cmake-rework-opencv.pc-gene.patch
 create mode 100644 package/opencv/opencv-0002-cmake-fix-gstreamer-check-conditions.patch

--
2.1.2

#1 lore raw

PATCH v4 1/9 package/opencv: update opencv options after last version bump

Update OPENCV_CONF_OPTS following its last bump to version 2.4.10.

---
changes v3 -> v4:
- new patch

---
 package/opencv/opencv.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/opencv/opencv.mk +8 -0
index 5fc7387..271e751 100644
@@ -18,6 +18,12 @@ OPENCV_CONF_OPTS += \
 	-DBUILD_PERF_TESTS=$(if $(BR2_PACKAGE_OPENCV_BUILD_PERF_TESTS),ON,OFF) \
 	-DBUILD_TESTS=$(if $(BR2_PACKAGE_OPENCV_BUILD_TESTS),ON,OFF)
 
+ifneq ($(BR2_PACKAGE_OPENCV_BUILD_TESTS)$(BR2_PACKAGE_OPENCV_BUILD_PERF_TESTS),)
+OPENCV_CONF_OPTS += -DINSTALL_TEST=ON
+else
+OPENCV_CONF_OPTS += -DINSTALL_TEST=OFF
+endif
+
 # OpenCV build options
 OPENCV_CONF_OPTS += \
 	-DBUILD_WITH_STATIC_CRT=OFF      \
@@ -66,6 +72,7 @@ OPENCV_CONF_OPTS += \
 	-DBUILD_opencv_ts=$(if $(BR2_PACKAGE_OPENCV_LIB_TS),ON,OFF)             \
 	-DBUILD_opencv_video=$(if $(BR2_PACKAGE_OPENCV_LIB_VIDEO),ON,OFF)       \
 	-DBUILD_opencv_videostab=$(if $(BR2_PACKAGE_OPENCV_LIB_VIDEOSTAB),ON,OFF) \
+	-DBUILD_opencv_viz=OFF \
 	-DBUILD_opencv_world=OFF
 
 # Hardware support options.
@@ -159,6 +166,7 @@ OPENCV_CONF_OPTS += \
 	-DWITH_OPENMP=OFF  \
 	-DWITH_OPENNI=OFF  \
 	-DWITH_UNICAP=OFF  \
+	-DWITH_VTK=OFF     \
 	-DWITH_XINE=OFF
 
 OPENCV_DEPENDENCIES += zlib
Signature · 1 line
2.1.2
#2 lore raw

PATCH v4 2/9 package/opencv: add Qt5 support

In reply to Samuel Martin

Starting with the 2.4.6 release, OpenCV supports both Qt4 and Qt5, but only one can be enable at the same time.

Since Buildroot does not support Qt4/Qt5 co-existence, we keep the Qt support knob as a boolean, but make it depend on BR2_PACKAGE_QT or BR2_PACKAGE_QT5, and automatically uses the enabled one.

Note that we usually use 'select ...' to express the dependencies between packages, but in this case, we cannot since the Qt4/Qt5 co-exist`ence exclusion is not handled by a simple choice, but by a dependency. This makes impossible using 'select ...' for the Qt support knob without triggering a circular dependency at the kconfig level.

Besides, we already use 'depends on ...' to express the dependencies with some "big" packages (like xorg or libgtk2). qt or qt5* packages are fairly big. So, I don't think it will hurt that much to use a 'depends on ...' statement in this case.

---
changes v3 -> v4:
- rebase
- rename _OPT -> _OPTS options
- rework qt backend selection (Yann)

changes v2 -> v3:
- rebase
- remove duplicate qt/qt5 dependencies (Yann)
- add missing 'depends on' to the comment about qt4

changes v1 -> v2:
- rebase
- update threads support dependency for qt5

---
 package/opencv/Config.in | 35 ++++++++++++++++++++++++++++-------
 package/opencv/opencv.mk |  4 ++--
 2 files changed, 30 insertions(+), 9 deletions(-)
package/opencv/Config.in +28 -7
index d648e5e..33e2a66 100644
@@ -187,16 +187,37 @@ config BR2_PACKAGE_OPENCV_WITH_PNG
 
 config BR2_PACKAGE_OPENCV_WITH_QT
 	bool "qt backend support"
-	depends on BR2_INSTALL_LIBSTDCPP
-	depends on !BR2_avr32 # qt
-	depends on BR2_USE_MMU # qt
-	depends on BR2_PACKAGE_OPENCV_LIB_HIGHGUI
-	select BR2_PACKAGE_QT
+	depends on BR2_PACKAGE_QT || BR2_PACKAGE_QT5
+	select BR2_PACKAGE_OPENCV_QT_BACKEND  if BR2_PACKAGE_QT
+	select BR2_PACKAGE_OPENCV_QT5_BACKEND if BR2_PACKAGE_QT5
+	help
+	  Enable Qt support for OpenCV.
+
+	  This uses whatever Qt version you enabled: Qt4 or Qt5.
+
+	  If Qt4 is already enabled, then QtTest and QtGui modules and STL support
+	  will be enabled as well.
+
+	  If Qt5 is already enabled, then the following components will be enabled
+	  as well: base, concurrent, test, gui and widgets.
+
+config BR2_PACKAGE_OPENCV_QT_BACKEND
+	bool
 	select BR2_PACKAGE_QT_STL
 	select BR2_PACKAGE_QT_GUI_MODULE
 	select BR2_PACKAGE_QT_TEST
-	help
-	  Use Qt with QtTest module and STL support
+
+config BR2_PACKAGE_OPENCV_QT5_BACKEND
+	bool
+	select BR2_PACKAGE_QT5BASE
+	select BR2_PACKAGE_QT5BASE_CONCURRENT
+	select BR2_PACKAGE_QT5BASE_TEST
+	select BR2_PACKAGE_QT5BASE_GUI
+	select BR2_PACKAGE_QT5BASE_WIDGETS
+
+comment "qt backend needs either Qt4 or Qt5"
+	depends on !BR2_PACKAGE_QT && !BR2_PACKAGE_QT5
+	depends on !BR2_avr32
 
 config BR2_PACKAGE_OPENCV_WITH_TIFF
 	bool "tiff support"
package/opencv/opencv.mk +2 -2
index 271e751..b527e53 100644
@@ -214,8 +214,8 @@ OPENCV_CONF_OPTS += -DWITH_PNG=OFF
 endif
 
 ifeq ($(BR2_PACKAGE_OPENCV_WITH_QT),y)
-OPENCV_CONF_OPTS += -DWITH_QT=4
-OPENCV_DEPENDENCIES += qt
+OPENCV_CONF_OPTS += -DWITH_QT=$(if $(BR2_PACKAGE_QT),4,5)
+OPENCV_DEPENDENCIES += $(if $(BR2_PACKAGE_QT),qt,qt5base)
 else
 OPENCV_CONF_OPTS += -DWITH_QT=OFF
 endif
Signature · 1 line
2.1.2
#3 lore raw

PATCH v4 3/9 package/opencv: add python/numpy support

In reply to Samuel Martin

opencv_python module needs python-numpy because it uses some numpy headers in this wrapper.

A patch in the OpenCV's build-system is also needed to prevent it from trying to run python for numpy detection. This patch has already been integrated upstream.

---
changes v3 -> v4:
- rebase
- rename _OPT -> _OPTS
- remove python/numpy patch (merged upstream since opencv bump)

changes v2 -> v3:
- rebase
- add fetch uri in the opencv's patch (Yann)
- move pyhton module knob under the multi-line if block about python deps (Yann)

changes v1 -> v2:
- rebase
- use patch merged upstream

---
 package/opencv/Config.in |  7 ++++++-
 package/opencv/opencv.mk | 18 ++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)
package/opencv/Config.in +6 -1
index 33e2a66..f8c9dc1 100644
@@ -84,7 +84,12 @@ config BR2_PACKAGE_OPENCV_LIB_PHOTO
 	help
 	  Include opencv_photo module into the OpenCV build.
 
-comment "opencv_python module requires numpy which is not yet available."
+config BR2_PACKAGE_OPENCV_LIB_PYTHON
+	bool "python"
+	depends on BR2_PACKAGE_PYTHON
+	help
+	  Include opencv_python module into the OpenCV build.
+	  No python example is installed.
 
 config BR2_PACKAGE_OPENCV_LIB_STITCHING
 	bool "stitching"
package/opencv/opencv.mk +16 -2
index b527e53..eece04f 100644
@@ -66,7 +66,6 @@ OPENCV_CONF_OPTS += \
 	-DBUILD_opencv_objdetect=$(if $(BR2_PACKAGE_OPENCV_LIB_OBJDETECT),ON,OFF) \
 	-DBUILD_opencv_ocl=OFF                                                  \
 	-DBUILD_opencv_photo=$(if $(BR2_PACKAGE_OPENCV_LIB_PHOTO),ON,OFF)       \
-	-DBUILD_opencv_python=OFF                                               \
 	-DBUILD_opencv_stitching=$(if $(BR2_PACKAGE_OPENCV_LIB_STITCHING),ON,OFF) \
 	-DBUILD_opencv_superres=$(if $(BR2_PACKAGE_OPENCV_LIB_SUPERRES),ON,OFF) \
 	-DBUILD_opencv_ts=$(if $(BR2_PACKAGE_OPENCV_LIB_TS),ON,OFF)             \
@@ -149,7 +148,6 @@ OPENCV_CONF_OPTS += \
 	-DBUILD_PNG=OFF	    \
 	-DBUILD_TIFF=OFF    \
 	-DBUILD_ZLIB=OFF    \
-	-DBUILD_NEW_PYTHON_SUPPORT=OFF \
 	-DINSTALL_C_EXAMPLES=OFF       \
 	-DINSTALL_PYTHON_EXAMPLES=OFF  \
 	-DINSTALL_TO_MANGLED_PATHS=OFF
@@ -236,6 +234,22 @@ else
 OPENCV_CONF_OPTS += -DWITH_V4L=OFF -DWITH_LIBV4L=OFF
 endif
 
+ifeq ($(BR2_PACKAGE_OPENCV_LIB_PYTHON),y)
+OPENCV_CONF_OPTS += \
+	-DBUILD_opencv_python=ON \
+	-DBUILD_NEW_PYTHON_SUPPORT=ON \
+	-DPYTHON_EXECUTABLE=$(HOST_DIR)/usr/bin/python2                               \
+	-DPYTHON_INCLUDE_DIR=$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) \
+	-DPYTHON_LIBRARY=$(STAGING_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR).so   \
+	-DPYTHON_NUMPY_INCLUDE_DIR=$(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages/numpy/core/include \
+	-DPYTHON_NUMPY_VERSION=$(PYTHON_NUMPY_VERSION)
+OPENCV_DEPENDENCIES += python python-numpy
+else
+OPENCV_CONF_OPTS += \
+	-DBUILD_opencv_python=ON \
+	-DBUILD_NEW_PYTHON_SUPPORT=OFF
+endif
+
 # Installation hooks:
 define OPENCV_CLEAN_INSTALL_DOC
 	$(RM) -fr $(TARGET_DIR)/usr/share/OpenCV/doc
Signature · 1 line
2.1.2
#4 lore raw

PATCH v4 4/9 package/opencv: add Gstreamer-1 support

In reply to Samuel Martin

Starting with the 2.4.10 release, OpenCV supports both Gstreamer-0.10 and Gstreamer-1, but only one can be enable at the same time.

This change adds a patch making sure the Gstreamer detection done by OpenCV reflects the user selection.

This patch has been sent upstream [1]

[1] https://github.com/Itseez/opencv/pull/3310

---
changes v3 -> v4:
- new patch

---
 package/opencv/Config.in                           | 30 ++++++---
 ...0002-cmake-fix-gstreamer-check-conditions.patch | 78 ++++++++++++++++++++++
 package/opencv/opencv.mk                           |  9 ++-
 3 files changed, 108 insertions(+), 9 deletions(-)
 create mode 100644 package/opencv/opencv-0002-cmake-fix-gstreamer-check-conditions.patch
package/opencv/Config.in +22 -8
index f8c9dc1..4a4c2af 100644
@@ -145,18 +145,32 @@ config BR2_PACKAGE_OPENCV_WITH_FFMPEG
 comment "ffmpeg support needs a toolchain w/ largefile, IPv6"
 	depends on !(BR2_LARGEFILE && BR2_INET_IPV6)
 
+choice
+	prompt "gstreamer backend support"
+	depends on BR2_PACKAGE_GSTREAMER || BR2_PACKAGE_GSTREAMER1
+	help
+	  Enable Gstreamer support for OpenCV.
+
+config BR2_PACKAGE_OPENCV_WITH_GSTREAMER_NONE
+	bool "none"
+
+config BR2_PACKAGE_OPENCV_WITH_GSTREAMER1
+	bool "gtreamer-1.x"
+	depends on BR2_PACKAGE_GSTREAMER1
+	select BR2_PACKAGE_GST1_PLUGINS_BASE
+	select BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_APP
+
 config BR2_PACKAGE_OPENCV_WITH_GSTREAMER
-	bool "gstreamer support"
-	depends on BR2_USE_MMU # gstreamer -> libglib2
-	depends on BR2_USE_WCHAR # gstreamer -> libglib2
-	depends on BR2_TOOLCHAIN_HAS_THREADS # gstreamer -> libglib2
-	select BR2_PACKAGE_GSTREAMER
+	bool "gtreamer-0.10"
+	depends on BR2_PACKAGE_GSTREAMER
 	select BR2_PACKAGE_GST_PLUGINS_BASE
 	select BR2_PACKAGE_GST_PLUGINS_BASE_PLUGIN_APP
 
-comment "gstreamer support needs a toolchain w/ wchar, threads"
-	depends on BR2_USE_MMU
-	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
+endchoice
+
+comment "gstreamer backend needs either Gstreamer-0.10 or Gstreamer-1"
+	depends on !BR2_PACKAGE_GSTREAMER && !BR2_PACKAGE_GSTREAMER1
+	depends on BR2_USE_MMU # gstreamer -> libglib2
 
 config BR2_PACKAGE_OPENCV_WITH_GTK
 	bool "gtk support"
package/opencv/opencv-0002-cmake-fix-gstreamer-check-conditions.patch new file +78 -0

78 lines not on this page · raw message

package/opencv/opencv.mk +8 -1
index eece04f..374f3a3 100644
@@ -177,9 +177,16 @@ OPENCV_CONF_OPTS += -DWITH_FFMPEG=OFF
 endif
 
 ifeq ($(BR2_PACKAGE_OPENCV_WITH_GSTREAMER),y)
-OPENCV_CONF_OPTS += -DWITH_GSTREAMER=ON
+OPENCV_CONF_OPTS += -DWITH_GSTREAMER_0_10=ON
 OPENCV_DEPENDENCIES += gstreamer gst-plugins-base
 else
+OPENCV_CONF_OPTS += -DWITH_GSTREAMER_0_10=OFF
+endif
+
+ifeq ($(BR2_PACKAGE_OPENCV_WITH_GSTREAMER1),y)
+OPENCV_CONF_OPTS += -DWITH_GSTREAMER=ON
+OPENCV_DEPENDENCIES += gstreamer1 gst1-plugins-base
+else
 OPENCV_CONF_OPTS += -DWITH_GSTREAMER=OFF
 endif
 
Signature · 1 line
2.1.2
#5 lore raw

PATCH v4 5/9 package/opencv: define modules inter-dependencies

In reply to Samuel Martin

OpenCV allows to enable/disable the selection of modules (a.k.a. opencv libraries). These modules depend one on the others; these dependencies are already handled by the build-system (CMake).

However, the way we handled them in Buildroot was not really clean. For each opencv module, there is a kconfig option, but we forced the corresponding cmake config option without checking for module dependencies.

This patch replicates the modules' dependency relations in the Config.in, so that the selection of the user will actually be built.

---
changes v3 -> v4:
- rebase
- update ts module dependencies

changes v2 -> v3:
- rebase
- fix typo in commit log (Yann)
- update A/R/T tags

changes v1 -> v2:
- rebase

---
 package/opencv/Config.in | 77 ++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 62 insertions(+), 15 deletions(-)
package/opencv/Config.in +62 -15
index 4a4c2af..1e33020 100644
@@ -8,6 +8,8 @@ menuconfig BR2_PACKAGE_OPENCV
 	  OpenCV (Open Source Computer Vision) is a library of programming
 	  functions for real time computer vision.
 
+	  Note that the opencv_core module is automatically enabled.
+
 	  http://opencv.org/
 
 if BR2_PACKAGE_OPENCV
@@ -16,110 +18,155 @@ comment "OpenCV modules"
 
 config BR2_PACKAGE_OPENCV_LIB_CALIB3D
 	bool "calib3d"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
 	help
 	  Include opencv_calib3d module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_CONTRIB
 	bool "contrib"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_ML
+	select BR2_PACKAGE_OPENCV_LIB_OBJDETECT
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_contrib module into the OpenCV build.
 
+# opencv_core module is automatically enabled when OpenCV package is selected
+
 config BR2_PACKAGE_OPENCV_LIB_FEATURES2D
 	bool "features2d"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_FLANN
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	help
 	  Include opencv_features2d module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_FLANN
 	bool "flann"
-	default y
+	# opencv_core dependency is already enabled
 	help
 	  Include opencv_flann module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_GPU
 	bool "gpu"
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_LEGACY
+	select BR2_PACKAGE_OPENCV_LIB_OBJDETECT
+	select BR2_PACKAGE_OPENCV_LIB_PHOTO
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_gpu module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_HIGHGUI
 	bool "highgui"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	help
 	  Include opencv_highgui module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	bool "imgproc"
-	default y
+	# opencv_core dependency is already enabled
 	help
 	  Include opencv_imgproc module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_LEGACY
 	bool "legacy"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_ML
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_legacy module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_ML
 	bool "ml (machine learning)"
-	default y
+	# opencv_core dependency is already enabled
 	help
 	  Include opencv_ml module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_NONFREE
 	bool "nonfree"
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	help
 	  Include opencv_nonfree module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_OBJDETECT
 	bool "objdetect"
-	default y
+	# opencv_core dependency is already enabled
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	help
 	  Include opencv_objdetect module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_PHOTO
 	bool "photo"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	help
 	  Include opencv_photo module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_PYTHON
 	bool "python"
 	depends on BR2_PACKAGE_PYTHON
+	# opencv_core dependency is already enabled
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_CONTRIB
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
+	select BR2_PACKAGE_OPENCV_LIB_FLANN
+	select BR2_PACKAGE_OPENCV_LIB_HIGHGUI
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_LEGACY
+	select BR2_PACKAGE_OPENCV_LIB_ML
+	select BR2_PACKAGE_OPENCV_LIB_OBJDETECT
+	select BR2_PACKAGE_OPENCV_LIB_PHOTO
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_python module into the OpenCV build.
 	  No python example is installed.
 
 config BR2_PACKAGE_OPENCV_LIB_STITCHING
 	bool "stitching"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_OBJDETECT
 	help
 	  Include opencv_stitching module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_SUPERRES
 	bool "superres"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_superres "super resolution" - module into the OpenCV
 	  build.
 
 config BR2_PACKAGE_OPENCV_LIB_TS
 	bool "ts (touchscreen)"
+	# opencv_core dependency is already enabled
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
 	select BR2_PACKAGE_OPENCV_LIB_HIGHGUI
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_ts module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_VIDEO
 	bool "video"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
 	help
 	  Include opencv_video module into the OpenCV build.
 
 config BR2_PACKAGE_OPENCV_LIB_VIDEOSTAB
 	bool "videostab"
-	default y
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
+	select BR2_PACKAGE_OPENCV_LIB_HIGHGUI
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_PHOTO
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
 	help
 	  Include opencv_videostab module into the OpenCV build.
 
Signature · 1 line
2.1.2
#6 lore raw

PATCH v4 6/9 package/opencv: add hidden symbol BR2_PACKAGE_OPENCV_USE_DEPRECATED_HEADERS

In reply to Samuel Martin

This new hidden symbol aims to automatically select all OpenCV modules required when another package use the deprecated OpenCV 'cv.h' headers.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- rebase
- update A/R/T tags

changes v1 -> v2:
- new patch

---
 package/opencv/Config.in | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
package/opencv/Config.in +15 -0
index 1e33020..6bba0f3 100644
@@ -14,6 +14,21 @@ menuconfig BR2_PACKAGE_OPENCV
 
 if BR2_PACKAGE_OPENCV
 
+config BR2_PACKAGE_OPENCV_USE_DEPRECATED_HEADERS
+	bool
+	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
+	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
+	select BR2_PACKAGE_OPENCV_LIB_HIGHGUI
+	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
+	select BR2_PACKAGE_OPENCV_LIB_LEGACY
+	select BR2_PACKAGE_OPENCV_LIB_ML
+	select BR2_PACKAGE_OPENCV_LIB_OBJDETECT
+	select BR2_PACKAGE_OPENCV_LIB_PHOTO
+	select BR2_PACKAGE_OPENCV_LIB_VIDEO
+	help
+	  Select all required modules needed by the deprecated OpenCV API
+	  (cv.h, cvaux.h, cxcore.h, etc).
+
 comment "OpenCV modules"
 
 config BR2_PACKAGE_OPENCV_LIB_CALIB3D
Signature · 1 line
2.1.2
#7 lore raw

PATCH v4 7/9 package/opencv: fix opencv.pc file generation

In reply to Samuel Martin

This patch reworks the opencv.pc file generation to make it properly work with pkg-config, especially when PKG_CONFIG_SYSROOT_DIR and or PKG_CONFIG_LIBDIR environment variables are set.

This patch is consecutive to some previous works/discussions [1].

This patch has been sent upstream [2].

Fixes:
http://autobuild.buildroot.net/results/e8a/e8a859276db34aff87ef181b0cce98916b0afc90/

[1] http://lists.busybox.net/pipermail/buildroot/2014-October/107670.html
[2] https://github.com/Itseez/opencv/pull/3305

Cc Vicente Olivert Riera <[email protected]>

---
changes v3 -> v4:
- new patch

---
 ...VGenPkgconfig.cmake-rework-opencv.pc-gene.patch | 156 +++++++++++++++++++++
 1 file changed, 156 insertions(+)
 create mode 100644 package/opencv/opencv-0001-cmake-OpenCVGenPkgconfig.cmake-rework-opencv.pc-gene.patch
package/opencv/opencv-0001-cmake-OpenCVGenPkgconfig.cmake-rework-opencv.pc-gene.patch new file +156 -0
new file mode 100644
index 0000000..89f377b
@@ -0,0 +1,156 @@
+From e9be21e48eb91d908b1f710c0cf4d3926a351277 Mon Sep 17 00:00:00 2001
+From: Samuel Martin <[email protected]>
+Date: Fri, 3 Oct 2014 00:32:40 +0200
+Subject: [PATCH] cmake/OpenCVGenPkgconfig.cmake: rework opencv.pc generation
+
+Using absolute path to locate the components in the "Libs:" field of the
+*.pc can badly break cross-compilation, especially when building
+statically linked objects.
+
+Indeed, pkg-config automatically replaces the '-I...' and '-L...' paths
+when the PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_LIBDIR environment
+variables are set [1]. This feature is very helpful and common in
+cross-compilation framework like Buildroot [2,3].
+
+When there are absolute paths in the *.pc files, pkg-config won't be
+able to do the path substitions for these paths when the afromentioned
+environment variables are set.
+In such case, since the prefix is the target one, not the sysroot one,
+these libraries' abolute paths will point to:
+- in the best case: a non-existing file (i.e. these files do not exists
+  on the host system;
+- at worst: the host system's libraries. This will make the linking
+  failed because these host system's libraries will most likely not be
+  build for the target architecture [4].
+
+So, this patch replace the components' absolute paths by the form:
+  -L<libdir> -l<libname>
+
+This way, the linker will be able to resolve each dependency path,
+whatever the kind of objects/build (shared object or static build) it
+is dealing with.
+
+Note that for static link, the library order does matter [5]. The order
+of the opencv components has been carefully chosen to comply with this
+requirement.
+
+[1] http://linux.die.net/man/1/pkg-config
+[2] http://buildroot.org/
+[3] http://git.buildroot.net/buildroot/tree/package/pkgconf/pkg-config.in
+[4] http://autobuild.buildroot.net/results/e8a/e8a859276db34aff87ef181b0cce98916b0afc90/build-end.log
+[5] http://stackoverflow.com/questions/45135/linker-order-gcc
+
+Signed-off-by: Samuel Martin <[email protected]>
+
+---
+Note: this patch properly applies on top of the master branch, though it
+      has been written on top of the 2.4 branch.
+---
+ cmake/OpenCVGenPkgconfig.cmake | 60 ++++++++++++++++++++++++++++++------------
+ 1 file changed, 43 insertions(+), 17 deletions(-)
+
+diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake
+index fa57db9..1f40308 100644
+--- a/cmake/OpenCVGenPkgconfig.cmake
++++ b/cmake/OpenCVGenPkgconfig.cmake
+@@ -8,10 +8,6 @@
+ #
+ # ${BIN_DIR}/unix-install/opencv.pc -> For use *with* "make install"
+ # -------------------------------------------------------------------------------------------
+-set(prefix      "${CMAKE_INSTALL_PREFIX}")
+-set(exec_prefix "\${prefix}")
+-set(libdir      "") #TODO: need link paths for OpenCV_EXTRA_COMPONENTS
+-set(includedir  "\${prefix}/${OPENCV_INCLUDE_INSTALL_PATH}")
+ 
+ if(CMAKE_BUILD_TYPE MATCHES "Release")
+   set(ocv_optkind OPT)
+@@ -34,43 +30,73 @@ ocv_list_unique(OpenCV_EXTRA_COMPONENTS)
+ ocv_list_reverse(OpenCV_LIB_COMPONENTS)
+ ocv_list_reverse(OpenCV_EXTRA_COMPONENTS)
+ 
++
++#set the components' libdir
++set(OpenCV_libdir "lib")
++
++list(LENGTH OpenCV_LIB_COMPONENTS _tmp)
++
++if(_tmp GREATER 0)
++  list(GET OpenCV_LIB_COMPONENTS 0 _tmp)
++  get_target_property(libpath ${_tmp} LOCATION_${CMAKE_BUILD_TYPE})
++  #need better solution....
++  if(libpath MATCHES "3rdparty")
++    set(OpenCV_libdir "share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}")
++  else()
++    set(OpenCV_libdir "${OPENCV_LIB_INSTALL_PATH}")
++  endif()
++endif()
++
++
+ #build the list of components
+ set(OpenCV_LIB_COMPONENTS_ "")
+ foreach(CVLib ${OpenCV_LIB_COMPONENTS})
+-  get_target_property(libpath ${CVLib} LOCATION_${CMAKE_BUILD_TYPE})
+-  get_filename_component(libname "${libpath}" NAME)
+ 
+-  if(INSTALL_TO_MANGLED_PATHS)
+-    set(libname "${libname}.${OPENCV_VERSION}")
+-  endif()
++  get_target_property(_libpath ${CVLib} LOCATION_${CMAKE_BUILD_TYPE})
++  get_filename_component(_libname "${_libpath}" NAME_WE)
++  string(REGEX REPLACE "^lib" "" _libname "${_libname}")
+ 
+-  #need better solution....
+-  if(libpath MATCHES "3rdparty")
+-    set(installDir "share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}")
++  # wolrd is a special target whose its library should come first, especially for
++  # static link.
++  if("${CVLib}" MATCHES "world")
++    set(OpenCV_LIB_COMPONENTS_ "-l${_libname} ${OpenCV_LIB_COMPONENTS_}")
+   else()
+-    set(installDir "${OPENCV_LIB_INSTALL_PATH}")
++    set(OpenCV_LIB_COMPONENTS_ "${OpenCV_LIB_COMPONENTS_} -l${_libname}")
+   endif()
+ 
+-  set(OpenCV_LIB_COMPONENTS_ "${OpenCV_LIB_COMPONENTS_} \${exec_prefix}/${installDir}/${libname}")
+ endforeach()
+ 
++set(OpenCV_LIB_COMPONENTS "-L\${libdir} ${OpenCV_LIB_COMPONENTS_}")
++
++
+ # add extra dependencies required for OpenCV
+-set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_})
+ if(OpenCV_EXTRA_COMPONENTS)
+   foreach(extra_component ${OpenCV_EXTRA_COMPONENTS})
+ 
+-    if(extra_component MATCHES "^-[lL]" OR extra_component MATCHES "[\\/]")
++    if(extra_component MATCHES "^-[lL]")
+       set(maybe_l_prefix "")
++      set(libname "${extra_component}")
++    elseif(extra_component MATCHES "[\\/]")
++      get_filename_component(libname "${extra_component}" NAME_WE)
++      get_filename_component(libdir "${extra_component}" DIRECTORY)
++      string(REGEX REPLACE "^lib" "" libname "${libname}")
++      set(maybe_l_prefix "-L${libdir} -l")
+     else()
+       set(maybe_l_prefix "-l")
++      set(libname "${extra_component}")
+     endif()
+ 
+-    set(OpenCV_LIB_COMPONENTS "${OpenCV_LIB_COMPONENTS} ${maybe_l_prefix}${extra_component}")
++    set(OpenCV_LIB_COMPONENTS "${OpenCV_LIB_COMPONENTS} ${maybe_l_prefix}${libname}")
+ 
+   endforeach()
+ endif()
+ 
+ #generate the .pc file
++set(prefix      "${CMAKE_INSTALL_PREFIX}")
++set(exec_prefix "\${prefix}")
++set(libdir      "\${exec_prefix}/${OpenCV_libdir}")
++set(includedir  "\${prefix}/${OPENCV_INCLUDE_INSTALL_PATH}")
++
+ if(INSTALL_TO_MANGLED_PATHS)
+   set(OPENCV_PC_FILE_NAME "opencv-${OPENCV_VERSION}.pc")
+ else()
+-- 
+2.1.2
+
Signature · 1 line
2.1.2
#8 lore raw

PATCH v4 8/9 package/vlc: add opencv support

In reply to Samuel Martin

Add OpenCV support for video filter in vlc.

vlc source code still includes the headers from the deprecated OpenCV API.

---
changes v3 -> v4:
- rebase
- rename _OPT -> _OPTS

changes v2 -> v3:
- rebase
- update A/R/T tags

changes v1 -> v2:
- new patch

---
 package/vlc/Config.in | 1 +
 package/vlc/vlc.mk    | 7 +++++++
 2 files changed, 8 insertions(+)
package/vlc/Config.in +1 -0
index cdb0d16..ede9269 100644
@@ -11,6 +11,7 @@ config BR2_PACKAGE_VLC
 	depends on BR2_USE_WCHAR
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	select BR2_PACKAGE_LIBVORBIS if BR2_PACKAGE_OPUS
+	select BR2_PACKAGE_OPENCV_USE_DEPRECATED_HEADERS if BR2_PACKAGE_OPENCV
 	help
 	  VLC is a free and open source cross-platform multimedia player
 	  and framework that plays most multimedia files as well as DVD,
package/vlc/vlc.mk +7 -0
index 0b275f2..d884873 100644
@@ -124,6 +124,13 @@ else
 VLC_CONF_OPTS += --disable-glx
 endif
 
+ifeq ($(BR2_PACKAGE_OPENCV),y)
+VCL_CONF_OPTS += --with-opencv
+VLC_DEPENDENCIES += opencv
+else
+VLC_CONF_OPTS += --without-opencv
+endif
+
 ifeq ($(BR2_PACKAGE_OPUS),y)
 VLC_CONF_OPTS += --enable-opus
 VLC_DEPENDENCIES += libvorbis opus
Signature · 1 line
2.1.2
#9 lore raw

PATCH v4 9/9 package/gstreamer1/gst1-plugins-bad: rework opencv plugin dependencies

In reply to Samuel Martin

gst1 opencv plugin source code still include OpenCV's headers from its deprecated API.

Use the newly introduced BR2_PACKAGE_OPENCV_USE_DEPRECATED_HEADERS to select all required OpenCV module dependencies.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- rebase
- update A/R/T tags

changes v1 -> v2:
- new patch

---
 package/gstreamer1/gst1-plugins-bad/Config.in | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
package/gstreamer1/gst1-plugins-bad/Config.in +1 -9
index c455aca..e59620f 100644
@@ -437,15 +437,7 @@ config BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_OPENCV
 	# Remove the following opencv modules when gstreamer fixes the
 	# problem of including the old "cv.h" header
 	# bug: https://bugzilla.gnome.org/show_bug.cgi?id=725163
-	select BR2_PACKAGE_OPENCV_LIB_CALIB3D
-	select BR2_PACKAGE_OPENCV_LIB_CONTRIB
-	select BR2_PACKAGE_OPENCV_LIB_FEATURES2D
-	select BR2_PACKAGE_OPENCV_LIB_FLANN
-	select BR2_PACKAGE_OPENCV_LIB_IMGPROC
-	select BR2_PACKAGE_OPENCV_LIB_LEGACY
-	select BR2_PACKAGE_OPENCV_LIB_ML
-	select BR2_PACKAGE_OPENCV_LIB_OBJDETECT
-	select BR2_PACKAGE_OPENCV_LIB_VIDEO
+	select BR2_PACKAGE_OPENCV_USE_DEPRECATED_HEADERS
 	help
 	  GStreamer OpenCV Plugins
 
Signature · 1 line
2.1.2