标签:
#ubuntu mate,xfce,unity 均可通过
#安装必要的依赖
sudo apt-get install build-essential cmake
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
#官方opencv3.1 http://opencv.org/downloads.html
#或者到我云共享 http://pan.baidu.com/s/1c2HPNd2
unzip opencv-3.1.0.zip -d ~
cd ~/opencv-3.1.0
mkdir build
cd build/
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.1 ..
#( $(nproc)变量返回cpu核心,全速编译&&终端无输出,重定向到make.log文件&&make时间较长)
sudo make -j $(nproc) &> make.log
cat make.log #查看make结果
#(终端无输入,完毕后直接返回,结果可以cat make-install.log)
sudo make install &>make-install.log
cat make-install.log #查看install结果
#加入动态链接库
sudo sh -c ‘echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf‘
sudo ldconfig
sudo gedit /etc/profile #在最后加入两行
#若无gedit命令,sudo apt-get install gedit
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
#最后
将ippicv中的64位lib文件复制到/usr/local/lib下
位于: ~ /opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx/lib/intel64/libippicv.a
测试成功!
测试代码:
#include <opencv2\opencv.hpp> using namespace cv; int _tmain(int argc, _TCHAR* argv[]) { Mat testImage = imread("D:\\opencv\\Hydrangeas.jpg"); Mat grayImage; cvtColor(testImage, grayImage, CV_RGB2GRAY); imshow("color", testImage); imshow("gray", grayImage); waitKey(0); return 0; }
标签:
原文地址:http://www.cnblogs.com/zoudaiyu/p/5555887.html