我已经尝试了整个周末 - 周六/周日和周一花了几个小时但无济于事。我正在关注 gstreamer 插件编写者指南
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-boiler-project-stamp.html。在尝试 gstreamer 插件程序之前,我已经安装了 gstreamer-0.10(sudo apt-get install 方法)和 OpenCV 2.4。我正在使用默认前缀(用于之前/usr/local/lib/gstreamer-0.10
的插件测试)./configure
sudo make && sudo make install
我设法生成了样板代码。现在我添加了一个 cvcreateImage 像
static GstFlowReturn
gst_cvtestfilter_chain (GstPad * pad, GstBuffer * buf)
{
Gstcvtestfilter *filter;
GstBuffer *outbuf;
IplImage* cvImage = cvCreateImage(cvSize(cvwidth,cvheight),cvdepth, cvchannels);
.
.
}
如果 cvImage 行被注释,一切都会顺利进行。所有测试都正常。如果我不评论该行,由于某种原因链接 OpenCV 会失败。
我修改了makefile.am
在 src 目录中添加 OpenCV 标志为
# Note: plugindir is set in configure
##############################################################################
# TODO: change libgstcvtestfilter.la to something else, e.g. libmysomething.la #
##############################################################################
plugin_LTLIBRARIES = libgstcvtestfilter.la
##############################################################################
# TODO: for the next set of variables, name the prefix if you named the .la, #
# e.g. libmysomething.la => libmysomething_la_SOURCES #
# libmysomething_la_CFLAGS #
# libmysomething_la_LIBADD #
# libmysomething_la_LDFLAGS #
##############################################################################
# sources used to compile this plug-in
libgstcvtestfilter_la_SOURCES = gstcvtestfilter.c gstcvtestfilter.h
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstcvtestfilter_la_CFLAGS = $(GST_CFLAGS) $(OPENCV_CFLAGS)
libgstcvtestfilter_la_LIBADD = $(GST_LIBS) $(OPENCV_LIBS)
libgstcvtestfilter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstcvtestfilter_la_LIBTOOLFLAGS = --tag=disable-static
# headers we need but don't want installed
noinst_HEADERS = gstcvtestfilter.h
我还configure.ac
通过添加在父目录中进行了修改
dnl *** opencv ***
translit(dnm, m, l) AM_CONDITIONAL(USE_OPENCV, true)
dnl we specify a max. version too because we set CV_NO_BACKWARD_COMPATIBILITY
dnl and don't want the build to break when a new opencv version comes out.
dnl Need to adjust this upwards once we know that our code compiles fine with
dnl a new version and the no-backward-compatibility define. (There doesn't
dnl seem to be a switch to suppress the warnings the cvcompat.h header
dnl causes.)
PKG_CHECK_MODULES(OPENCV, opencv >= 2.0.0 opencv <= 3.1.0 , [
AC_PROG_CXX
AC_LANG_CPLUSPLUS
OLD_CPPFLAGS=$CPPFLAGS
CPPFLAGS=$OPENCV_CFLAGS
AC_CHECK_HEADER(highgui.h, HAVE_HIGHGUI="yes", HAVE_HIGHGUI="no")
AC_CHECK_HEADER(cvaux.h, HAVE_CVAUX="yes", HAVE_CVAUX="no")
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"
elif test "x$HAVE_CVAUX" = "xno"; then
AC_MSG_RESULT(cvaux.h could not be found.)
HAVE_OPENCV="no"
else
HAVE_OPENCV="yes"
AC_SUBST(OPENCV_CFLAGS)
AC_SUBST(OPENCV_LIBS)
fi
], [
HAVE_OPENCV="no"
AC_MSG_RESULT(no)
])
编译很好 - 没有错误。
现在,当我在管道中运行插件时,我收到了这条消息
(gst-plugin-scanner:6396): GStreamer-WARNING **: Failed to load plugin '/usr/local/lib/gstreamer-0.10/libgstcvtestfilter.so': /usr/local/lib/gstreamer-0.10/libgstcvtestfilter.so: undefined symbol: cvCreateImage
所以很明显我所在的opencv/usr/local/lib
没有正确链接。
sudo gedit /etc/bash.bashrc
包含
#Added By me
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
#Added By me
PATH=$PATH:/opt/Xilinx/13.4/ISE_DS/ISE/bin/lin
export PATH
GST_PLUGIN_PATH=$GST_PLUGIN_PATH:/usr/local/lib/gstreamer-0.10
export GST_PLUGIN_PATH
sudo gedit /etc/ld.so.conf.d/opencv.conf
包含
/usr/local/lib
sudo gedit /etc/ld.so.conf.d/gst.conf
包含
/usr/local/lib/gstreamer-0.10
sudo ldconfig -v
sudo gedit ~/.bashrc
包含
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/gstreamer-0.10
ldd /usr/local/lib/gstreamer-0.10/libgstcvtestfilter.so
没有给出奇怪的opencv依赖
linux-gate.so.1 => (0xb77b6000)
libgstreamer-0.10.so.0 => /usr/lib/i386-linux-gnu/libgstreamer-0.10.so.0 (0xb76b0000)
libgobject-2.0.so.0 => /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 (0xb7661000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb7567000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb754c000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb73a7000)
libgmodule-2.0.so.0 => /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 (0xb73a2000)
libxml2.so.2 => /usr/lib/i386-linux-gnu/libxml2.so.2 (0xb7255000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb7228000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb721f000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb721a000)
libffi.so.6 => /usr/lib/i386-linux-gnu/libffi.so.6 (0xb7213000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb71d7000)
/lib/ld-linux.so.2 (0xb77b7000)
libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb71c0000)
我的操作系统是 32 位 12.04 Ubuntu。如果有人能指出我正确的方向,我将不胜感激。谢谢。
更新:(2012 年 6 月 29 日)
从 OpenCV 经验中汲取灵感configure.ac
,如果有人感兴趣,我修改了 for OpenGL
AC_CHECK_HEADER(
GL/gl.h,
AC_DEFINE(
[HAVE_OPENGL],
[],
Define to 1 if you have the <GL/gl.h> header file.
)
OPENGL_LIBS="$X_LIBS -lGL -lGLU -lpthread -lglut -lGLEW"
opengl=yes,
AC_MSG_WARN([*** no GL/gl.h -- opengl and SDL support disabled])
)
AC_SUBST(OPENGL_CFLAGS)
AC_SUBST(OPENGL_LIBS)
dnl AC_ARG_WITH(
dnl opengl-cflags,
dnl [ --with-opengl-cflags=PATH Specify OpenGL cflags],
dnl OPENGL_CFLAGS="$withval", OPENGL_CFLAGS="")
dnl AC_ARG_WITH(
dnl opengl-libs,
dnl [ --with-opengl-libs=PATH Specify OpenGL libs (default is -lGL -lGLU -lpthread)],
dnl OPENGL_LIBS="$withval", OPENGL_LIBS="-lGL -lGLU -lpthread -lglut -lGLEW")
dnl AC_SUBST(OPENGL_CFLAGS)
dnl AC_SUBST(OPENGL_LIBS)