当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 2020-11-05
- [开源] .Net 使用 ORM 访问 华为GaussDB数据库
- jsliang 求职系列 - 07 - Promise
- 一分钟全面看懂forsage智能合约全球共享以太坊矩阵计划
- 重返全球第三,小米做对了什么?
- 技术总监7年总结,如何进行正确的沟通?
- 框架-SPI四种模式+通用设备驱动实现-源码
- 2035我们将建成这样的国家
- Blockchain weekly: the development of digital currency is written into the 14th five year plan; Biden invited senior adviser of MIT digital currency program to join the presidential transition team; V
- awk实现类sql的join操作
猜你喜欢

打工人,打工魂,抽终身会员,成为人上人!

我用 Python 找出了删除我微信的所有人并将他们自动化删除了

华为在5G手机市场占据绝对优势,市调机构对小米的市占出现分歧

Interpretation of deepmind's latest paper: the causal reasoning algorithm in discrete probability tree is proposed for the first time

Liteos message queuing

学习记录并且简单分析

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

2020-11-05

学习记录并且简单分析

What are the necessary laws and regulations to know when entering the Internet?
随机推荐
Returning to the third place in the world, what did Xiaomi do right?
Application of four ergodic square of binary tree
Chapter 5 programming
“他,程序猿,35岁,被劝退”:不要只懂代码,会说话,胜过10倍默默努力
阿里云的MaxCompute数加(原ODPS)用的怎样?
Solution of DEV-C + + unable to debug in Windows Environment
2020-11-05
Design by contract (DBC) and its application in C language
Tips and skills of CSP examination
关于adb连接手机offline的问题解决
. net large data concurrency solution
SQL 速查
API生命周期的5个阶段
uni-app实战仿微信app开发
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
聊聊Go代码覆盖率技术与最佳实践
vim-配置教程+源码
Travel notes of Suzhou
B站stm32视频学习
性能压测时,并发压力增加,系统响应时间和吞吐量如何变化