Opened 13 years ago

Closed 13 years ago

#323 closed enhancement (needs_more_info)

[patch] properly detect and compile with opencv 2.2+

Reported by: Martin Matuska Owned by:
Priority: normal Component: avfilter
Version: unspecified Keywords: opencv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

For libavfilter/vf_libopencv.c starting with OpenCV version 2.2 only the opencv_core and opencv_imgproc headers and libraries are required. Example patch below adds proper support for this case. This is relevant for master and oldabi.

diff --git a/configure b/configure
index fd4b034..ea74df3 100755
--- a/configure
+++ b/configure
@@ -2900,6 +2900,8 @@ enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
 enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
 enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
 enabled libopencv  && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
+enabled libopencv  && check_pkg_config opencv opencv2/imgproc/imgproc_c.h cvCreateImageHeader && add_cflags -DHAVE_OPENCV2 ||
+			require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
 enabled librtmp    && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
 enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index e1b51c5..f22b2bc 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -25,8 +25,13 @@
 
 /* #define DEBUG */
 
+#ifdef HAVE_OPENCV2
+#include <opencv2/core/core_c.h>
+#include <opencv2/imgproc/imgproc_c.h>
+#else
 #include <opencv/cv.h>
 #include <opencv/cxcore.h>
+#endif
 #include "libavutil/avstring.h"
 #include "libavutil/file.h"
 #include "avfilter.h"

Change History (2)

comment:1 by Carl Eugen Hoyos, 13 years ago

Status: newopen

Could you explain which problem your patch fixes?

comment:2 by Michael Niedermayer, 13 years ago

Resolution: needs_more_info
Status: openclosed

Please reopen the ticket once somone explains what this patch fixes

Note: See TracTickets for help on using tickets.