当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- . net large data concurrency solution
- Summary of template engine
- LeanCloud 十月变化
- Builder pattern
- 前后端分离跨域问题解决方案
- Builder pattern
- [open source]. Net uses ORM to access Huawei gaussdb database
- Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple
- The birth of a new integrated memory and computing chip is conducive to the application of artificial intelligence~
- 关于adb连接手机offline的问题解决
猜你喜欢

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

The first open source Chinese Bert pre training model in the financial field

实验

Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization

契约式设计(Dbc)以及其在C语言中的应用

Flink的sink实战之一:初探

VIM configuration tutorial + source code

佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事

小米、OPPO在欧洲市场继续飙涨,小米更是直逼苹果

Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple
随机推荐
TypeScript(1-2-2)
Mac环境安装Composer
Drink soda, a bottle of soda water 1 yuan, two empty bottles can change a bottle of soda, give 20 yuan, how much soda can you
How does Alibaba cloud's maxcompute add (original ODPs) work?
SQL 速查
. net large data concurrency solution
Js中常见的内存泄漏场景
Arduino IDE搭建ESP8266开发环境,文件下载过慢解决方法 | ESP-01制作WiFi开关教程,改造宿舍灯
wanxin finance
别再在finally里面释放资源了,解锁个新姿势!
函数分类大pk!sigmoid和softmax,到底分别怎么用?
技术总监7年总结,如何进行正确的沟通?
Flink的sink实战之一:初探
One minute comprehensive understanding of forsage smart contract global shared Ethereum matrix plan
浅谈OpenGL之DSA
Rabbitmq (1) - basic introduction
第二章编程练习
2020-11-05
TypeScript(1-2-2)
The birth of a new integrated memory and computing chip is conducive to the application of artificial intelligence~