1. 程式人生 > >Ubuntu同時安裝OpenCV2和OpenCV3

Ubuntu同時安裝OpenCV2和OpenCV3

Ubuntu下檢視linux版本

pkg-config --modversion opencv 

sudo apt-get install build-essential libgtk2.0-dev libvtk5-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev libtbb-dev  
mkdir build && cd build

輸入命令

cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_TBB=ON -D WITH_V4L=ON -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320 .. 
make 
sudo make install 

緊接著需要配置下檔案,通過修改bashrc檔案來設定PKG_ CONFIG_PATH(後來發現好像還需要改一下LD_LIBRARY_PATH)

sudo gedit ~/.bashrc  
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv320/lib/pkgconfig 
export LD_LIBRARY_PATH=$PKG_CONFIG_PATH:/usr/local/opencv320/lib