opencv_contrib 配置中常见问题的解决

来源:互联网 发布:电脑管家for mac 编辑:程序博客网 时间:2024/05/22 19:53


在opencv3.0中,如果需要SIFT,SURF等算法的时候,需要配置opencv_contrib .

罗列一下自己在配置的过程中遇到的问题:

1.

CMake Error at D:/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:23 (ocv_download):  Unknown CMake command "ocv_download".Call Stack (most recent call first):  D:/opencv_contrib-3.2.0/modules/dnn/cmake/download_protobuf.cmake:51 (ocv_protobuf_download)  D:/opencv_contrib-3.2.0/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:30 (include)  D:/opencv_contrib-3.2.0/modules/dnn/CMakeLists.txt:35 (include)
解决方案:可能使用的是opencv_contrib-3.2.0版本,网上有好多的教程,下载protobuf-cpp-3.1.0.tar.gz等,但是可能由于本人的技术有限,使用这种方法等不到解决。
所以使用的第二种方法,下载opencv_contrib-3.0.0版本,顺利通过配置。

2. error LNK2026 模块对于 SAFESEH 映像是不安全的

解决方案:属性->链接器->高级->Image Has Safe Exception Handler:NO:/SAFESEH 

问题得到解决

测试代码

#include <iostream>#include <opencv2/opencv.hpp>  #include <opencv2/xfeatures2d.hpp>using namespace cv; using namespace std;int main(){//Create SIFT class pointerPtr<Feature2D> f2d = xfeatures2d::SIFT::create();//读入图片Mat img_1 = imread("1.tif");Mat img_2 = imread("2.tif");//Detect the keypointsvector<KeyPoint> keypoints_1, keypoints_2;f2d->detect(img_1, keypoints_1);f2d->detect(img_2, keypoints_2);//Calculate descriptors (feature vectors)Mat descriptors_1, descriptors_2;f2d->compute(img_1, keypoints_1, descriptors_1);f2d->compute(img_2, keypoints_2, descriptors_2);//Matching descriptor vector using BFMatcherBFMatcher matcher;vector<DMatch> matches;matcher.match(descriptors_1, descriptors_2, matches);Mat img_matches;drawMatches(img_1, keypoints_1, img_2, keypoints_2, matches, img_matches);imshow("match", img_matches);waitKey(0);}




2 0
原创粉丝点击