opencv ubuntu 10.04

zz  http://blog.163.com/lyn_21@126/blog/static/6547308120113289394648/

步骤1:更新下载更新软件包列表信息
sunnewt@sunnewt-desktop:~$ apt-get update


步骤2:查询OpenCV相关软件包

sunnewt@sunnewt-desktop:~$ apt-cache search opencv
libcv-dev - development files for libcv
libcv4 - computer vision library
libcvaux-dev - development files for libcvaux
libcvaux4 - computer vision extension library
libhighgui-dev - development files for libhighgui
libhighgui4 - computer vision GUI library
opencv-doc - OpenCV documentation and examples
python-opencv - Python bindings for the computer vision library
harpia - Image Processing/Computer Vision Automatic Prgm. Tool

步骤3:安装相关软件包
如果只是单单运行OpenCV程序,仅需安装libcv1,libcvaux1,libhighgui1。
sunnewt@sunnewt-desktop:~$ apt-get install libcv4 libcvaux4 libhighgui4

如果要使用OpenCV来开发,那么还需要安装libcv-dev,libcvaux-dev,libhighgui-dev和harpia。
sunnewt@sunnewt-desktop:~$ apt-get install libcv-dev libcvaux-dev libhighgui-dev harpia

接下来,只需等待。。。

测试是否安装成功,马上拿例子来运行:
/*    程序名:hello.c
 *    功能:从磁盘中读入图像文件,并将图像显示在屏幕上
*/
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
    IplImage* pImg; //声明IplImage指针
    //载入图像
    if( argc == 2 && (pImg = cvLoadImage( argv[1], 1)) != 0 )
    {
        cvNamedWindow( "Image", 1 ); //创建窗口
        cvShowImage( "Image", pImg ); //显示图像
        cvWaitKey(0); //等待按键
        cvDestroyWindow( "Image" );//销毁窗口
        cvReleaseImage( &pImg ); //释放图像
        return 0;
    }
    return -1;
}

#  Makefile
OBJECT=hello
CC=gcc
CFLAGS=`pkg-config --cflags opencv`
LDFLAGS=`pkg-config --libs opencv`

all: $(OBJECT)

clean:
    rm -f $(OBJECT)

---------------------------------------------------

pkg-config --libs opencv
    -lcv -lhighgui -lcvaux -lml -lcxcore

pkg-config --cflags opencv
    -I/usr/include/opencv  

 

 

posted @ 2012-10-19 17:25  goooooooooo  阅读(476)  评论(0编辑  收藏  举报