NASA Astrobee Robot Software  Astrobee Version:
Flight software for the Astrobee robots operating inside the International Space Station.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
matching.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 #ifndef INTEREST_POINT_MATCHING_H_
19 #define INTEREST_POINT_MATCHING_H_
20 
21 #include <boost/optional.hpp>
22 #include <opencv2/features2d/features2d.hpp>
23 #include <Eigen/Core>
24 
25 #include <vector>
26 #include <string>
27 #include <map>
28 
29 namespace interest_point {
30 
32  public:
33  DynamicDetector(int min_features, int max_features, int retries,
34  double min_thresh, double default_thresh, double max_thresh,
35  double too_many_ratio, double too_few_ratio);
36  virtual ~DynamicDetector(void) {}
37  void Detect(const cv::Mat& image,
38  std::vector<cv::KeyPoint>* keypoints,
39  cv::Mat* keypoints_description);
40  virtual void DetectImpl(const cv::Mat& image,
41  std::vector<cv::KeyPoint>* keypoints) = 0;
42  virtual void ComputeImpl(const cv::Mat& image,
43  std::vector<cv::KeyPoint>* keypoints,
44  cv::Mat* keypoints_description) = 0;
45  virtual void TooFew(void) = 0;
46  virtual void TooMany(void) = 0;
47  void GetDetectorParams(int& min_features, int& max_features, int& max_retries, double& min_thresh,
48  double& default_thresh, double& max_thresh, double& too_many_ratio, double& too_few_ratio);
49 
51 
52  protected:
56  };
57 
59  private:
60  DynamicDetector* detector_;
61  std::string detector_name_;
62 
63  // A feature detector cannot be copied, since it has a pointer
65  FeatureDetector& operator=(const FeatureDetector&);
66 
67  public:
68  // Here on purpose invalid values are set, so the user explicitly sets them.
69  FeatureDetector(std::string const& detector_name = "SURF", int min_features = 0, int max_features = 0,
70  int retries = 0, double min_thresh = 0, double default_thresh = 0, double max_thresh = 0,
71  double too_many_ratio = 0, double too_few_ratio = 0);
72  ~FeatureDetector(void);
73 
74  void Reset(std::string const& detector_name, int min_features = 0, int max_features = 0, int retries = 0,
75  double min_thresh = 0, double default_thresh = 0, double max_thresh = 0, double too_many_ratio = 0,
76  double too_few_ratio = 0);
77 
78  void Detect(const cv::Mat& image, std::vector<cv::KeyPoint>* keypoints,
79  cv::Mat* keypoints_description);
80 
81  std::string GetDetectorName() const {return detector_name_;}
82 
83  void GetDetectorParams(int& min_features, int& max_features, int& max_retries, double& min_thresh,
84  double& default_thresh, double& max_thresh, double& too_many_ratio, double& too_few_ratio);
85 
86  friend bool operator== (FeatureDetector const& A, FeatureDetector const& B) {
87  return (A.detector_name_ == B.detector_name_);
88  }
89 
90  DynamicDetector& dynamic_detector() { return *detector_; }
91  };
92 
100  void FindMatches(const cv::Mat& img1_descriptor_map, const cv::Mat& img2_descriptor_map,
101  std::vector<cv::DMatch>* matches, boost::optional<int> hamming_distance = boost::none,
102  boost::optional<double> goodness_ratio = boost::none);
103 } // namespace interest_point
104 
105 #endif // INTEREST_POINT_MATCHING_H_
interest_point::DynamicDetector::max_features_
int max_features_
Definition: matching.h:53
interest_point::FindMatches
void FindMatches(const cv::Mat &img1_descriptor_map, const cv::Mat &img2_descriptor_map, std::vector< cv::DMatch > *matches, boost::optional< int > hamming_distance=boost::none, boost::optional< double > goodness_ratio=boost::none)
Definition: matching.cc:358
interest_point::DynamicDetector::min_thresh_
double min_thresh_
Definition: matching.h:54
interest_point::DynamicDetector::default_thresh_
double default_thresh_
Definition: matching.h:54
interest_point::DynamicDetector::min_features_
int min_features_
Definition: matching.h:53
interest_point::FeatureDetector::Reset
void Reset(std::string const &detector_name, int min_features=0, int max_features=0, int retries=0, double min_thresh=0, double default_thresh=0, double max_thresh=0, double too_many_ratio=0, double too_few_ratio=0)
Definition: matching.cc:288
interest_point::DynamicDetector::last_keypoint_count
int last_keypoint_count(void)
Definition: matching.h:50
interest_point::FeatureDetector
Definition: matching.h:58
interest_point::DynamicDetector::last_keypoint_count_
int last_keypoint_count_
Definition: matching.h:55
interest_point::FeatureDetector::operator==
friend bool operator==(FeatureDetector const &A, FeatureDetector const &B)
Definition: matching.h:86
interest_point::DynamicDetector::max_retries_
int max_retries_
Definition: matching.h:53
interest_point::DynamicDetector::too_many_ratio_
double too_many_ratio_
Definition: matching.h:54
interest_point::FeatureDetector::Detect
void Detect(const cv::Mat &image, std::vector< cv::KeyPoint > *keypoints, cv::Mat *keypoints_description)
Definition: matching.cc:343
interest_point::DynamicDetector::max_thresh_
double max_thresh_
Definition: matching.h:54
interest_point::DynamicDetector::TooMany
virtual void TooMany(void)=0
interest_point::DynamicDetector::GetDetectorParams
void GetDetectorParams(int &min_features, int &max_features, int &max_retries, double &min_thresh, double &default_thresh, double &max_thresh, double &too_many_ratio, double &too_few_ratio)
Definition: matching.cc:96
interest_point::DynamicDetector::ComputeImpl
virtual void ComputeImpl(const cv::Mat &image, std::vector< cv::KeyPoint > *keypoints, cv::Mat *keypoints_description)=0
interest_point::FeatureDetector::~FeatureDetector
~FeatureDetector(void)
Definition: matching.cc:281
interest_point::DynamicDetector::dynamic_thresh_
double dynamic_thresh_
Definition: matching.h:54
interest_point::DynamicDetector::~DynamicDetector
virtual ~DynamicDetector(void)
Definition: matching.h:36
interest_point::DynamicDetector::DetectImpl
virtual void DetectImpl(const cv::Mat &image, std::vector< cv::KeyPoint > *keypoints)=0
interest_point::FeatureDetector::GetDetectorParams
void GetDetectorParams(int &min_features, int &max_features, int &max_retries, double &min_thresh, double &default_thresh, double &max_thresh, double &too_many_ratio, double &too_few_ratio)
Definition: matching.cc:272
interest_point::DynamicDetector::DynamicDetector
DynamicDetector(int min_features, int max_features, int retries, double min_thresh, double default_thresh, double max_thresh, double too_many_ratio, double too_few_ratio)
Definition: matching.cc:83
interest_point::DynamicDetector::too_few_ratio_
double too_few_ratio_
Definition: matching.h:54
interest_point::FeatureDetector::GetDetectorName
std::string GetDetectorName() const
Definition: matching.h:81
interest_point::DynamicDetector
Definition: matching.h:31
interest_point::DynamicDetector::TooFew
virtual void TooFew(void)=0
interest_point::DynamicDetector::Detect
void Detect(const cv::Mat &image, std::vector< cv::KeyPoint > *keypoints, cv::Mat *keypoints_description)
Definition: matching.cc:109
interest_point::FeatureDetector::dynamic_detector
DynamicDetector & dynamic_detector()
Definition: matching.h:90
interest_point
Definition: brisk.h:25