1.
安装openCV2.3的依赖包,如果只用其基本功能用: sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev
sudo apt-get install libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
想用其所有功能,用以下命令:
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install pkg-config
sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3
sudo apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2
sudo apt-get install zlib1g-dbg zlib1g zlib1g-dev
sudo apt-get install libjasper-dev libjasper-runtime libjasper1
sudo apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
sudo apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog
sudo apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev
sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
sudo apt-get install libxine1-ffmpeg libxine-dev libxine1-bin
sudo apt-get install libunicap2 libunicap2-dev
sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
sudo apt-get install swig
sudo apt-get install libv4l-0 libv4l-dev
sudo apt-get install python-numpy
2.下载OpenCV-2.3.1
3.解压到home目录~/OpenCV-2.3.1(当然也可以是别的地方)
tar -xvf OpenCV-2.3.1a.tar.bz2
4. 创建一个发布opencv的目录,比如~/OpenCV-2.3.1/release
$ cd OpenCV-2.3.1
$ mkdir release
$ cd release
5. 执行以下命令:
$ cmake ..
$ make
$ sudo make install
6.更新链接库
$ ldconfig
7. 打开home下的./bashrc
$ gedit .bashrc
在文件最后加入以下内容:
export LD_LIBRARY_PATH=/home//OpenCV-2.3.1/release/lib
export PKG_CONFIG_PATH=/home//OpenCV-2.3.1/release/lib/pkgconfig
alias gcv="g++ `pkg-config --cflags opencv` `pkg-config --libs opencv`"
8. 把openCV里的例子编译一下:
$ cd /home//OpenCV-2.3.1/samples/c
$ chmod a+x build_all.sh
$ ./build_all.sh
9.由于我们已经在bashrc里创建了别名gcv,所以可以使用以下命令编译:
$ gcv hellocv.cpp
hellocv.cpp 一个简单的例子:
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp" using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
Mat img = imread("lena.jpg");
if(!img.data)
return -1;
namedWindow("Lena", CV_WINDOW_AUTOSIZE);
imshow("Lena", img);
waitKey();
return 0;
阅读(3105) | 评论(0) | 转发(1) |