opencv3.2.0+contirb+cmake

安装环境 vs2013+cv3.2+扩展包+cmake,64位

安装包下载途径,github
再此处选择opencv/opencv和opencv/contirb中3.2.0 tag
保证同一版本。
opencv库包含opencv,opencv_contrib,opencv_3rdparty
主体是opencv,包括大部分不用付费的部分。
扩展包opencv_contrib,付费部分,特别是xfeature模块里面的sift和surf
第三方库opencv_3rdparty,主体和扩展包所有需要下载的全部在此处。遇到下载不了,出错的基本在此处人工下载。


这是3.0的安装步骤
流程相同,本文只讲不同的出错解决方式。可以对照上文链接生成链接库和可执行程序。
个人理解,使用cmake gui,分为configure,generate两个步骤。
configure确认(包括下载),generate生成(对应vs编译器)


1.configure

configure包括用.cmake文件下载本地没有的文件
注意,由于网络原因,各种cmake出现的问题主要在这

CMake Warning at cmake/OpenCVUtils.cmake:865 (message):
Download: Local copy of opencv_ffmpeg.dll has invalid MD5 hash:
d41d8cd98f00b204e9800998ecf8427e (expected:
89c783eee1c47bfc733f08334ec2e31c)

Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:10 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:193 (include)
CMakeLists.txt:527 (include)


Downloading opencv_ffmpeg.dll...
CMake Error at cmake/OpenCVUtils.cmake:888 (file):
file DOWNLOAD MD5 mismatch

for file: [C:/research/opencv300/sources/3rdparty/ffmpeg/downloads/89c783eee1c47bfc733f08334ec2e31c/opencv_ffmpeg.dll]
expected MD5 sum: [89c783eee1c47bfc733f08334ec2e31c]
actual MD5 sum: [d41d8cd98f00b204e9800998ecf8427e]

Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:10 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:193 (include)
CMakeLists.txt:527 (include)


CMake Error at cmake/OpenCVUtils.cmake:892 (message):
Failed to download opencv_ffmpeg.dll.  Status=1;"unsupported protocol"
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:10 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:193 (include)
CMakeLists.txt:527 (include)

解决办法:
cmake,认文件,只要文件在就行。所以,自己从opencv 3rdparty
这个仓库,找对应文件的tag。把文件下载到对应目录里。

目标文件夹 新建文件夹 文件
opencv-3.2.0\3rdparty\ffmpeg opencv- 3.2.0\3rdparty\ffmpeg\downloads\a423363a6eb76d362ca6c406c96c8db6\ opencv_ffmpeg_64.dll
opencv-3.2.0\3rdparty\ffmpeg E:\opencv\opencv-3.2.0\3rdparty\ffmpeg\downloads\f081abd9d6ca7e425d340ce586f9c090 opencv_ffmpeg.dll
opencv-3.2.0\3rdparty\ippicv opencv-3.2.0\3rdparty\ippicv\downloads\windows-04e81ce5d0e329c3fbc606ae32cad44d ippicv_windows_20151201.zip

完成上面部分,就已经完成不包含contrib部分的configure(认证)了。
接下来是第一次generate生成。
此处一般不会出问题,有也是configure处造成的。
参考链接stackoverflow
相关博文


包含扩展包的configure

1.1 xfeature

同上面一样去对应tag下载文件

目标文件夹 新建文件夹 文件
opencv_contrib-3.2.0\modules\xfeatures2d|

opencv3.2.0+contirb+cmake_第1张图片
这是我下载的xfeature的部分,包括boostdesc和vgg。具体文件夹名字,已download_boostdesc.cmake中的md5来命名。

1.2 dnn

这部分我没去生成,毕竟不用深度神经网络

这里写图片描述
在cmake gui中取消勾选,错误估计和上文一样。

3.2.0的扩展包需要下载的只有这两个,常见错误代码

Downloading ...
CMake Error at /Users/Documents/opencv/source/opencv-3.2.0/cmake/OpenCVUtils.cmake:1045 (file):
file DOWNLOAD cannot open file for write.
Call Stack (most recent call first):
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/CMakeLists.txt:5 (include)

CMake Error at /Users/Documents/opencv/source/opencv-3.2.0/cmake/OpenCVUtils.cmake:1049 (message):
Failed to download . Status=
Call Stack (most recent call first):
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/CMakeLists.txt:5 (include)

这个解决方法是下载opencv master结点的
opencv_contrib-master/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake
opencv_contrib-master/modules/xfeatures2d/cmake/download_boostdesc.cmake
opencv_contrib-master/modules/xfeatures2d/cmake/download_vgg.cmake
替代务必见github上的链接

2.generate

gui一键搞定。

3.vs2013生成

opencv3.2.0+contirb+cmake_第2张图片

保证全部成功,失败的模块不会生成.lib,用到对应部分的函数时,会出错;其他部分使用正常。这部分我没生成dnn,所以只有110个。


在笔记本上下了vs2015+opencv3.1+contrib的蛮简单,也可以说比较稳定吧。contirb基本不用另外下载。
相比opencv3.2.0安装扩展包简单很多,因为3.2的OpenCVFindLibProtobuf.cmake等在库里面不是最新的,导致下载不了。
生成的链接库文件夹
opencv3.2.0+contirb+cmake_第3张图片
小技巧:往vs里面输入上面的.lib是不是很崩溃?
在该文件夹命令行搞定

E:\opencv\cv3.2binary\install\x64\vc12\lib>dir /b /w >libInfo.txt

E:\opencv\cv3.2binary\install\x64\vc12\lib>notepad libInfo.txt

3.xfeature.lib 测试

sift代码

#include 

#include 
#include 
#include 
#include 

using namespace cv;
using namespace std;

void sift(const std::string& file) {
    auto img = imread(file);
    Mat gray, res;
    cvtColor(img, gray, COLOR_BGR2GRAY);

    auto psift = xfeatures2d::SIFT::create();
    std::vector kp;
    psift->detect(gray, kp);

    drawKeypoints(gray, kp, res, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

    namedWindow("SIFT", 0);
    imshow("SIFT", res);
}

int main(int argc, char* argv[]) {

    //string material_dir = "assignment2_images/";
    //string answer_dir = "assignment2_answers/";

    //harris(material_dir + "butterfly.jpg");
    sift("lena.jpg");

    waitKey();

    return 0;
}
//代码来源,github抄的

opencv3.2.0+contirb+cmake_第4张图片

你可能感兴趣的:(opencv)