当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 3、 The parameters of the function
- 进入互联网得知道的必备法律法规有哪些?
- 机械硬盘随机IO慢的超乎你的想象
- Mac环境安装Composer
- 腾讯:阿里的大中台虽好,但也不是万能的!
- API生命周期的5个阶段
- SQL quick query
- wanxin finance
- Your random IO hard disk
- AI weekly: employees are allowed to voluntarily reduce salary; company response: employees are happy and satisfied; tiger tooth HR takes employees out of the company; Sweden forbids Huawei ZTE 5g equi
猜你喜欢

What is forsage Ethereum smart contract? What is the global decline of Ethereum

“他,程序猿,35岁,被劝退”:不要只懂代码,会说话,胜过10倍默默努力

Design by contract (DBC) and its application in C language

一分钟全面看懂forsage智能合约全球共享以太坊矩阵计划

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

Talking about, check the history of which famous computer viruses, 80% of the people do not know!

laravel8更新之速率限制改进

I used Python to find out all the people who deleted my wechat and deleted them automatically

wanxin finance

模板引擎的整理归纳
随机推荐
技术总监7年总结,如何进行正确的沟通?
Design by contract (DBC) and its application in C language
Five phases of API life cycle
awk实现类sql的join操作
Improvement of rate limit for laravel8 update
学习记录并且简单分析
区块链周报:数字货币发展写入十四五规划;拜登邀请MIT数字货币计划高级顾问加入总统过渡团队;委内瑞拉推出国营加密交易所
10 common software architecture patterns
构建者模式(Builder pattern)
Framework - SPI four modes + general device driver implementation - source code
The network adapter could not establish the connection
How does the system response time and throughput change with the increase of concurrency pressure during performance pressure testing
2035 we will build such a country
CSP考试须知与各种小技巧
I used Python to find out all the people who deleted my wechat and deleted them automatically
10个常见的软件架构模式
When to write disk IO after one byte of write file
喜获蚂蚁offer,定级p7,面经分享,万字长文带你走完面试全过程
Talk about go code coverage technology and best practices
Development of uni app imitating wechat app