OpenCV in Ubuntu 10.04
1. 安装opencv libraries.
sudo apt-get install libcv libcv-dev libcvaux libcvaux-dev libhighgui libhighgui-dev opencv-doc Python-opencv
2.安装完后,输入:
export LD_LIBRARY_PATH=/home/opencv/lib
export PKG_CONFIG_PATH=/home/opencv/lib/pkgconfig
都是opencv的默认路径
3. 检测OpenCV library的目录:
$ pkg-config –cflags opencv
(输出:-I/usr/include/opencv)
$ pkg-config –libs opencv
(输出:-lcxcore -lcv -lhighgui -lcvaux -lml)
4. 检测是否所有的Library文件都安装好了:
$ apt-cache search opencv
显示如下:
5. 显示图片的示例程序:
#include “highgui.h”
int main( int argc, char** argv )
{
IplImage* img = cvLoadImage( “lena512.bmp” );
cvNamedWindow( “E1″, CV_WINDOW_AUTOSIZE );
cvShowImage( “E1″, img );
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( “E1″ );
}
把lena512.bmp换成你要显示的图片文件。
6. 编译
g++ -I/usr/include/opencv -o e1 -lcv -lcxcore -lhighgui -lm e1.cpp
7. 运行
./e1
显示Lena