#安装必要的依赖
sudo apt-get install build-essential cmakesudo 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/1c2HPNd2unzip opencv-3.1.0.zip -d ~cd ~/opencv-3.1.0mkdir buildcd 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.logcat make-install.log #查看install结果#加入动态链接库sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'sudo ldconfigsudo gedit /etc/profile #在最后加入两行#若无gedit命令,sudo apt-get install geditPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfigexport PKG_CONFIG_PATH#pkg-config可以查看下面链接了解:http://www.cppblog.com/colorful/archive/2012/05/05/173750.aspx#最后将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; }上述测试未必成功!需要添加#include <opencv2/imgcodecs.hpp>http://blog.csdn.net/yonger_/article/details/52924516
http://embedonix.com/articles/image-processing/installing-opencv-3-1-0-on-ubuntu/