opencv_contrib 配置中常见问题的解决

本文介绍了在OpenCV 3.0中配置SIFT和SURF算法所需的步骤及解决过程中遇到的问题,包括配置opencv_contrib模块的具体方法,并提供了一个简单的特征匹配示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



在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 pointer
	Ptr<Feature2D> f2d = xfeatures2d::SIFT::create();
	//读入图片
	Mat img_1 = imread("1.tif");
	Mat img_2 = imread("2.tif");
	//Detect the keypoints
	vector<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 BFMatcher
	BFMatcher 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);
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值