forked from BloodAxe/OpenCV-Features-Comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FeatureAlgorithm.hpp
42 lines (29 loc) · 1.53 KB
/
FeatureAlgorithm.hpp
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
#ifndef FeatureAlgorithm_hpp
#define FeatureAlgorithm_hpp
#include <opencv2/opencv.hpp>
typedef std::vector<cv::KeyPoint> Keypoints;
typedef cv::Mat Descriptors;
typedef std::vector<cv::DMatch> Matches;
//! Represents combination of feature detector, descriptor extractor and matcher algorithms for test
class FeatureAlgorithm
{
public:
explicit FeatureAlgorithm(const std::string& name, cv::Ptr<cv::FeatureDetector> d, cv::Ptr<cv::DescriptorExtractor> e, bool useBruteForceMather);
explicit FeatureAlgorithm(const std::string& name, cv::Ptr<cv::Feature2D> featureEngine, bool useBruteForceMather);
//! Human-friendly name of detection/extraction/matcher combination.
std::string name;
//! If true, a KNN-matching and ratio test will be enabled for matching descriptors.
bool knMatchSupported;
//! Extracts feature points and compute descriptors from given image.
bool extractFeatures(const cv::Mat& image, Keypoints& kp, Descriptors& desc) const;
//! Finds correspondences using regular match.
void matchFeatures(const Descriptors& train, const Descriptors& query, Matches& matches) const;
//! KNN match features.
void matchFeatures(const Descriptors& train, const Descriptors& query, int k, std::vector<Matches>& matches) const;
private:
cv::Ptr<cv::Feature2D> featureEngine;
cv::Ptr<cv::FeatureDetector> detector;
cv::Ptr<cv::DescriptorExtractor> extractor;
cv::Ptr<cv::DescriptorMatcher> matcher;
};
#endif