首页 > 代码库 > ubuntu 安装 OpenCv 及其Qt的开发环境配置

ubuntu 安装 OpenCv 及其Qt的开发环境配置

ubuntu安装opencv

(1)安装编译opencv的环境

sudo apt-get -y install build-essential cmake pkg-config

(2)安装Image I/O库

sudo apt-get -y install libjpeg62-dev 
sudo apt-get -y install libtiff4-dev libjasper-dev

(3)安装GTK库

sudo apt-get -y install  libgtk2.0-dev

(4)安装Video I/O库

sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

(5)安装支持摄像头固件的库

sudo apt-get -y install libdc1394-22-dev

(6)安装视频流库

sudo apt-get -y install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev 

(7)安装python开发环境和python 数学库

sudo apt-get -y install python-dev python-numpy

(8)安装 Intel tbb library

sudo apt-get -y install libtbb-dev

(9)安装Qt开发库

sudo apt-get -y install libqt4-dev

(10)从http://opencv.org/中下载OpenCV,然后解压缩

tar -zxvf OpenCV-2.9.tar.bz2

创建编译目录

    cd OpenCV-2.9
    mkdir build
    cd build
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
    -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON 
    -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON 
    -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

开始编译(这个过程比较长,耐心等待)

 make

最后不要忘记安装

sudo make install

现在配置Qt下OpenCV的开发环境,从http://qt-project.org/下载集成开发环境,安装

然后打开QtCreator,点击File,选择New File or Project,选择Non-Qt Project ,选择Plain C++ Project, 点击choose

项目建立完成后会看到一个*.pro文件然后打开添加OpenCV的库

INCLUDEPATH += /usr/local/include

LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

然后就可以写程序了