当前位置:网站首页>C + + opencv4.3 sift matching
C + + opencv4.3 sift matching
2020-11-08 16:17:00 【Spiritual】
c++ opencv4.3 sift matching
main.cpp
int main()
{
vector<KeyPoint> keypoints1, keypoints2;
Mat img1,img2,descriptors1, descriptors2;
int numFeatures = 500;// The maximum number of feature points
int numlines = 50;// front 20 The best match
string path1 = "1.jpg";// picture 1
string path2 = "2.jpg";// picture 2
getDescriptors(numFeatures, path1, keypoints1, descriptors1, img1);// Drawing pictures 1 Characteristic point
getDescriptors(numFeatures, path2, keypoints2, descriptors2, img2);// Drawing pictures 2 Characteristic point
drawMatch(img1, keypoints1, descriptors1, img2, keypoints2, descriptors2, numlines);// Draw match points
return 0;
}
utils.cpp
#include "utils.h"
// Get feature point information
void getDescriptors( int numFeatures, string path, vector<KeyPoint>& keypoints, Mat& descriptors, Mat& img) {
img = imread(path);
Ptr<SIFT> detector = SIFT::create(numFeatures);
if (detector.empty())
throw runtime_error("fail to create detector!");
//detect keypoints;
;
detector->detect(img, keypoints);
cout << "img:" << keypoints.size() << endl;
//compute descriptors for keypoints;
//Sift Feature description extraction
cout << "< Computing descriptors for keypoints from images..." << endl;
detector->compute(img, keypoints, descriptors);
cout << endl << "Descriptors Size: " << descriptors.size() << " >" << endl;
cout << endl << "Descriptor's Column: " << descriptors.cols << endl << "Descriptor's Row: " << descriptors.rows << endl;
cout << ">" << endl;
//Draw And Match img1,img2 keypoints
Mat img_keypoints;
drawKeypoints(img, keypoints, img_keypoints, Scalar::all(-1), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imshow(path, img_keypoints);
}
// Draw matching feature points to
void drawMatch(Mat img1, vector<KeyPoint> keypoints1, Mat descriptors1, Mat img2, vector<KeyPoint> keypoints2, Mat descriptors2, int numlines) {
// Violent match
Ptr<DescriptorMatcher> descriptor_matcher = DescriptorMatcher::create("BruteForce");
vector<DMatch> matches;
descriptor_matcher->match(descriptors1, descriptors2, matches);
// Pick the best match before 20 individual
nth_element(matches.begin(), matches.begin() + numlines-1, matches.end());
matches.erase(matches.begin() + numlines-1, matches.end());
// Draw a match point line
Mat img_matches;
drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector< char>(), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imshow("Mathc", img_matches);
waitKey(0);
}

opencv4.3 Download address
https://download.csdn.net/download/qq_26696715/12459477
There is a problem adding QQ Group :686070107
版权声明
本文为[Spiritual]所创,转载请带上原文链接,感谢
边栏推荐
- Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
- Is there no way out for older programmers?
- Workers, workers soul, draw lifelong members, become a person!
- Elasticsearch 学习一(基础入门).
- 契约式设计(Dbc)以及其在C语言中的应用
- 关于update操作并发问题
- 重返全球第三,小米做对了什么?
- python开发qt程序读取图片的简单流程
- 机械硬盘随机IO慢的超乎你的想象
- How to solve the conflict when JD landed on Devops platform?
猜你喜欢

刚刚好,才是最理想的状态

Rabbitmq (1) - basic introduction

Recurrence of Apache kylin Remote Code Execution Vulnerability (cve-2020-1956)

GopherChina 2020大会

模板引擎的整理归纳

awk实现类sql的join操作

C + + things: from rice cookers to rockets, C + + is everywhere

Don't release resources in finally, unlock a new pose!

Comics: looking for the best time to buy and sell stocks

构建者模式(Builder pattern)
随机推荐
机械硬盘随机IO慢的超乎你的想象
阿里云加速增长,进一步巩固领先优势
LiteOS-消息队列
AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
rabbitmq(一)-基础入门
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Workers, workers soul, draw lifelong members, become a person!
Learn to record and analyze
Learn to record and analyze
Golang system ping program to detect the surviving host (any permission)
Talk about go code coverage technology and best practices
金融领域首个开源中文BERT预训练模型,熵简科技推出FinBERT 1.0
Framework - SPI four modes + general device driver implementation - source code
Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
write文件一个字节后何时发起写磁盘IO
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Golang ICMP Protocol detects viable hosts
打工人,打工魂,抽终身会员,成为人上人!
关于adb连接手机offline的问题解决
我用 Python 找出了删除我微信的所有人并将他们自动化删除了