编译opencv+opencv_contrib

编译opencv+opencv_contrib

遇到的问题:

本来opencv版本是3.1.0的,opencv_contrib时从github上直接master拉下来的。直接编译出现有关ocv_download的问题:

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)

网上搜到的答案说要改FILENAME为PACKAGE(差点就改了,但是我是centos系统,认为这个方法应该不好使,就没改),后来从github上直接抓到opencv源码管理员在issue下的回答:https://github.com/opencv/opencv_contrib/issues/1100

alalek commented on 31 Mar 2017
This configuration is not synchronized.
You should checkout “opencv_contrib” to 3.2.0 (git checkout 3.2.0 command). Also you can get it as ZIP archive by “tag”: https://github.com/opencv/opencv_contrib/archive/3.2.0.zip .
Or you should use “opencv” repository from GitHub “master” branch too.

我之前也在哪里看到有人说版本要和opencv一致,所以特意选了Tag 3.1.0 但还是clone下来的 可能不是真正的3.1.0版本,要下载ZIP或者在clone下来的git目录下切换分支到3.1.0:

git checkout 3.1.0

确认当前分支是3.1.0:
编译opencv+opencv_contrib_第1张图片
然后再加上下面的cmake指令重新编译opencv即可

cmake -D OPENCV_EXTRA_MODULES_PATH=[opencv_contrib]/modules -D [opencv_source_directory]

其中opencv_contrib是刚刚的切换过分支的opencv_contrib目录,opencv_source_directory是你的opencv源码的目录

你可能感兴趣的:(Linux,OpenCV)