opencv: fix configure check and build with opencv 2.1
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 17 Mar 2012 12:47:52 +0000 (12:47 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 17 Mar 2012 14:53:50 +0000 (14:53 +0000)
AC_CHECK_HEADERS() calls action-if-not-found also if just one of
the headers checked for is missing, which is not what we wanted.
Also, check for highgui_c.h instead of highgui.hpp.

https://bugzilla.gnome.org/show_bug.cgi?id=672226

configure.ac
ext/opencv/MotionCells.cpp
ext/opencv/MotionCells.h
ext/opencv/gstopencvutils.c
ext/opencv/gsttemplatematch.h
ext/opencv/motioncells_wrapper.cpp

index 9cf3de2..ec821e2 100644 (file)
@@ -1432,14 +1432,15 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [
     AC_LANG_CPLUSPLUS
     OLD_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=$OPENCV_CFLAGS
-    AC_CHECK_HEADERS(highgui.h opencv2/highgui/highgui.hpp, HAVE_HIGHGUI="yes", HAVE_HIGHGUI="no")
+    AC_CHECK_HEADERS([highgui.h opencv2/highgui/highgui_c.h])
     CPPFLAGS=$OLD_CPPFLAGS
     AC_LANG_C
-    if test "x$HAVE_HIGHGUI" = "xno"; then
-      AC_MSG_RESULT(highgui.h could not be found.)
-      HAVE_OPENCV="no"
-    else
+
+    if test $ac_cv_header_highgui_h = "yes" -o $ac_cv_header_opencv2_highgui_highgui_c_h = "yes" ; then
       HAVE_OPENCV="yes"
+    else
+      AC_MSG_RESULT([neither highgui.h nor opencv2/highgui/highgui_c.h could not be found])
+      HAVE_OPENCV="no"
     fi
   ], [
     HAVE_OPENCV="no"
index 5223bc7..6d18a99 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/* This breaks the build for reasons that aren't entirely clear to me yet */
+#if 0
+//#ifdef HAVE_CONFIG_H
+//#include "config.h"
+//#endif
+#endif
+
 #include <cstdlib>
 #include <errno.h>
 #include <math.h>
index c5d4b17..68a2fec 100644 (file)
 #define MOTIONCELLS_H_
 
 #include <cv.h>                 // includes OpenCV definitions
-#ifndef __OPENCV_OLD_CV_H__
+#ifdef HAVE_HIGHGUI_H
 #include <highgui.h>            // includes highGUI definitions
-#else
-#include <opencv2/highgui/highgui.hpp>            // includes highGUI definitions
+#endif
+#ifdef HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H
+#include <opencv2/highgui/highgui_c.h>            // includes highGUI definitions
 #endif
 #include <iostream>
 #include <fstream>
index dc42f90..8c72257 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "gstopencvutils.h"
 
 static gboolean
index 7e55ac6..8d99f98 100644 (file)
 
 #include <gst/gst.h>
 #include <cv.h>
-#ifndef __OPENCV_OLD_CV_H__
+#ifdef HAVE_HIGHGUI_H
 #include <highgui.h>            // includes highGUI definitions
-#else
-#include <opencv2/highgui/highgui.hpp>            // includes highGUI definitions
+#endif
+#ifdef HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H
+#include <opencv2/highgui/highgui_c.h>            // includes highGUI definitions
 #endif
 
 G_BEGIN_DECLS
index d509686..f55802b 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/* This breaks the build for reasons that aren't entirely clear to me yet */
+#if 0
+//#ifdef HAVE_CONFIG_H
+//#include "config.h"
+//#endif
+#endif
+
 #include <stdio.h>
 #include <limits.h>
 #include "motioncells_wrapper.h"