我的config文件:
-- General configuration for opencv 2.3.2 =====================================
--
-- Built as dynamic libs?: YES
-- Compiler: /usr/bin/c++
-- C++ flags (Release): -Wall -pthread -march=i686 -ffunction-sections -O3 -DNDEBUG -fomit-frame-pointer -msse -msse2 -mfpmath=387 -DNDEBUG
-- C++ flags (Debug): -Wall -pthread -march=i686 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
-- Linker flags (Release):
-- Linker flags (Debug):
--
-- GUI:
-- GTK+ 2.x: YES
-- GThread: YES
--
-- Media I/O:
-- ZLib: YES
-- JPEG: TRUE
-- PNG: TRUE
-- TIFF: TRUE
-- JPEG 2000: TRUE
-- OpenEXR: NO
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- XIMEA: NO
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES
-- FFMPEG: YES
-- codec: YES
-- format: YES
-- util: YES
-- swscale: YES
-- gentoo-style: YES
-- GStreamer: NO
-- UniCap: NO
-- PvAPI: NO
-- V4L/V4L2: Using libv4l
-- Xine: NO
--
-- Other third-party libraries:
-- Use IPP: NO
-- Use TBB: NO
-- Use ThreadingFramework: NO
-- Use Cuda: NO
-- Use Eigen: NO
--
-- Interfaces:
-- Python: YES
-- Python interpreter: /usr/bin/python2.6 -B (ver 2.6)
-- Python numpy: YES
-- Java: NO
--
-- Documentation:
-- Sphinx: NO
-- PdfLaTeX compiler: /usr/local/bin/pdflatex
-- Build Documentation: NO
--
-- Tests and samples:
-- Tests: YES
-- Examples: NO
--
-- Install path: /usr/local
--
-- cvconfig.h is in: ~/Downloads/trunk/opencv/release
-- -----------------------------------------------------------------
其中红色部分为重点。之前摄像头无法驱动,重新编译后改动的地方为dc1394.2和v4l那个(原来显示为1/1,现在为Using libv4l)。
测试程序选用sample:camshiftdemo,可以清晰捕捉到图像。
1.配置关键在于opencv的前期安装(关于视频IO的):
apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev
apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
apt-get install libxine1-ffmpeg libxine-dev libxine1-bin
apt-get install libunicap2 libunicap2-dev
apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
apt-get install swig
apt-get install libv4l-0 libv4l-dev
apt-get install python-numpy
apt-get install libpython2.6 python-dev python2.6-dev #You must install this for python support
2.准备完后,用svn获得最新的opencv:
cd ~/
svn co https://code.ros.org/svn/opencv/trunk
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
sudo make
sudo make install
3.测试
g++ `pkg-config opencv --libs --cflags opencv` -o camshiftdemo camshiftdemo.cpp
./camshiftdemo 有BUG说缺东西的试试export LD_LIBRARY_PATH=你的lib地址