-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.h
26 lines (21 loc) · 868 Bytes
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once
#include <vector>
#include <opencv2/core.hpp>
using namespace std;
using namespace cv;
void GetAlignedPointsFromMatch(const vector<KeyPoint>& imgpts1, const vector<KeyPoint>& imgpts2, const vector<DMatch>& matches, vector<KeyPoint>& pt_set1, vector<KeyPoint>& pt_set2){
for (unsigned int i=0; i<matches.size(); i++) {
assert(matches[i].queryIdx < imgpts1.size());
pt_set1.push_back(imgpts1[matches[i].queryIdx]);
assert(matches[i].trainIdx < imgpts2.size());
pt_set2.push_back(imgpts2[matches[i].trainIdx]);
}
}
void KeyPointsToPoints(const vector<KeyPoint>& kps, vector<Point2f>& ps) {
ps.clear();
for (unsigned int i=0; i<kps.size(); i++) ps.push_back(kps[i].pt);
}
void PointsToKeyPoints(const vector<Point2f>& ps, vector<KeyPoint>& kps) {
kps.clear();
for (unsigned int i=0; i<ps.size(); i++) kps.push_back(KeyPoint(ps[i],1.0f));
}