-
Notifications
You must be signed in to change notification settings - Fork 4
/
featuredpa.h
45 lines (36 loc) · 1.64 KB
/
featuredpa.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef FEATUREDPA_H
#define FEATUREDPA_H
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include <vector>
#include <iostream>
using namespace cv;
struct Feature {
std::vector<KeyPoint> keypoints_1;
std::vector<KeyPoint> keypoints_2;
std::vector<DMatch> matches;
std::vector<Point3f> worldPoint;
};
class FeatureDPA {
public:
FeatureDPA();
//-- Finds the matching features for two images
Feature findMatches(const Mat& img_1, const Mat& img_2, bool print=false);
//-- Display matches side-by-side in image. Access by print=true in @findMatches
void displayMatches(const Mat& img_1, const Mat& img_2,
const std::vector<KeyPoint>& keypoints_1, const std::vector<KeyPoint>& keypoints_2,
const std::vector<DMatch>& matches);
//-- Gives 3D points of two given features
Feature getWorldPoints(Feature features, const Matx34d& projMat1, const Matx34d& projMat2);
//-- estimate the pose of the robot based on word points
Mat estimatePose(Feature f1, Feature f2);
private:
Ptr<FastFeatureDetector> featureDetector;
Ptr<ORB> extractor;
BFMatcher matcher;
int get2DPointfs(Feature features, std::vector<Point2f> &pts1, std::vector<Point2f> &pts2);
int matchWorldPoints(std::vector<Point3f> w1, std::vector<Point3f> w2, std::vector<Point3f> &m1, std::vector<Point3f> &m2);
};
#endif // FEATUREDPA_H