OpenCV3.2.0 : https://github.com/opencv/opencv/releases/download/3.2.0/opencv-3.2.0-vc14.exe
opencv_contrib3.2.0 : https://github.com/opencv/opencv_contrib/archive/3.2.0.zip (可以根据自己本机已经配置的opencv版本下载对应的opencv_contrib)
opencv_contrib: https://github.com/opencv/opencv_contrib/tags
CMake(可以去官网下载较新的版本) : https://cmake.org/download/
ippicv_windows_20151201.zip包:https://download.csdn.net/download/qq_39707351/11110577
源路径选择的是opencv3.2.0安装目录下的sources目录,目的路径随意选择一个空目录即可;然后点击Configure后出现如下选择框:
选择对应环境即可,VS2017,win64;点finish;等待ing… 直到出现如下界面:
附:
有时候在第一次configure的时候会出现ippicv_windows_20151201.zip下载失败的问题:
解决方案:
手动下载ippicv_windows_20151201.zip包,下载链接:https://download.csdn.net/download/qq_39707351/11110577
之后在路径D:\OpenCV3.2.0\opencv\sources\3rdparty\ippicv\downloads\windows-04e81ce5d0e329c3fbc606ae32cad44d下替换即可;
往下拉直到找到OPENCV_EXTRA_MODULES_PATH 选择解压opencv_contrib目录下的modules文件夹,如下图(其他选项最好不要随意乱动,默认选项即可):
目录选好之后,点击Generate;继续等待ing…
下载链接: https://download.csdn.net/download/qq_39707351/10454808
1、首先在CMake的目的路径 D:\Documents\Projects\NewOpencv 下找到OpenCV.sln文件打开:
2、然后右击解决方案,选择重新生成解决方案,操作如下图所示,然后继续等待若干分钟ing…(这一步挺久的):
3、生成成功之后->右击CMakeTargets目录下的INSTALL->选择仅用于项目->仅生成INSTALL;如下图所示生成install文件,继续等待ing…:
4、显示成功1,失败后面都是0,恭喜就表示生成成功了。
生成成功之后,在目的路径会新生成一个Install文件夹,该文件夹就相当于结合了opencv_contrib的opencv库目录。
然后给它起个OpenCV3.2.0Environments_Debug方便以后找到和分辨,之后可以自己将该项目下的该配置文件保存出来,以后直接添加即可:
添加文件:
opencv_world320d.lib
opencv_xfeatures2d320d.lib
opencv_features2d320d.lib
#-----------------------------------------------------------------------------
##测试代码:
#include "stdafx.h"
#include"iostream"
#include"opencv.hpp"
#include"highgui.hpp"
#include"xfeatures2d.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat imageL0 = imread("Pattenimage_L.bmp");
Mat imageR0 = imread("Pattenimage_R.bmp");
Mat imageL1, imageR1;
GaussianBlur(imageL0, imageL1, Size(3, 3), 0.5);
GaussianBlur(imageR0, imageR1, Size(3, 3), 0.5);
//找出特征点
Ptrf2d = xfeatures2d::SURF::create();
vector keyPoint1, keyPoint2;
f2d->detect(imageL1, keyPoint1);
f2d->detect(imageR1, keyPoint2);
drawKeypoints(imageL1, keyPoint1, imageL1, Scalar::all(-1), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
drawKeypoints(imageR1, keyPoint2, imageR1, Scalar::all(-1), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
namedWindow("KeyPoints of imageL", 0);
namedWindow("KeyPoints of imageR", 0);
imshow("KeyPoints of imageL", imageL1);
imshow("KeyPoints of imageR", imageR1);
//特征点匹配
Mat descriptors_1, descriptors_2;
f2d->compute(imageL1, keyPoint1, descriptors_1);
f2d->compute(imageR1, keyPoint2, descriptors_2);
BFMatcher matcher;
vectormatches;
matcher.match(descriptors_1, descriptors_2, matches);
Mat imageOutput;
drawMatches(imageL1, keyPoint1, imageR1, keyPoint2, matches, imageOutput);
namedWindow("picture of matching", 0);
imshow("picture of matching", imageOutput);
waitKey(0);
return 0;
}