关于编译opencv_contrib的一些总结

首先说下我的编程环境: win10(64)位+VS2017+opencv3.3.1dubug(opencv2.4.9)

提到opencv2.4.9的原因:opencv2.4.9为十分经典的版本,如果在多次编译opencv_contrib未果的情况下,不妨可以退回到opencv2.4.9,实测在上述环境下,opencv2.4.9可以完美运行。

关于在opencv3.3.1dubug的环境下编译opencv_contrib的总结:
(1)在编译的期间,来来回回配置了好几次的opencv3.3.1,开始我的附加的依赖项为opencv_world331d.lib和opencv_world331.lib,后来在dubug的时候,发现在加载各种dll的时候,速度奇慢无比,后来在删除opencv_world331.lib后,速度就很快了。

(2)对于遇到了 缺少msvcp120d.dll和msvcr120d.dll问题时,可以去网上下载64位的dll,并将其放在opencv x64下的bin文件夹里
(3)

opencv3.3.1中SurfFeatureDetector、SurfDescriptorExtractor、BruteForceMatcher这三个的使用方法已经和原先2.4版本前不一样了。

使用方法示例如下:

  
   Ptr<SURF> detector = SURF::create(minHessian);
   detector->detect(img_1, keypoints_1);


    Ptr<SURF> extractor = SURF::create();
    extractor->compute(img_1, keypoints_1, descriptors_1);



       Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce");
matcher->match(descriptors_1, descriptors_2, matches);
引用自  https://blog.csdn.net/qsy2000/article/details/70230827
(4)最后附上配置好的环境下,进行SURF检测的代码

#include <iostream>
#include <opencv2\opencv.hpp>
#include <opencv2\xfeatures2d\nonfree.hpp>
using namespace std;
using namespace cv;    
using namespace xfeatures2d;         //在opencv3中,一定要先声明xfeatures2d这个名称空间

int main()
{
	Mat scrimg = imread("D:\\2.jpg");
	int minHessian = 400;
	vector<KeyPoint>keypoint;
	Ptr<SURF> detector = SURF::create(minHessian);   //注意此处与opencv2中语法的不同
	detector->detect(scrimg, keypoint);              //注意此处与opencv2中语法的不同
	Mat img_keypoint;
	drawKeypoints(scrimg, keypoint, img_keypoint, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
	imshow("效果图", img_keypoint);
	waitKey(0);
	return 0;


}

关于在编写代码时的一些注意事项,已经在代码的注释中标明。

猜你喜欢

转载自blog.csdn.net/forever_xixi/article/details/80150113