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
然後就可以寫程式了