any_detector.h
Go to the documentation of this file.
00001 #ifndef VSLAM_SYSTEM_ANY_DETECTOR_H
00002 #define VSLAM_SYSTEM_ANY_DETECTOR_H
00003 
00004 #include <opencv2/features2d/features2d.hpp>
00005 #include <opencv2/nonfree/nonfree.hpp>
00006 
00007 namespace vslam_system {
00008 
00009 class AnyDetector : public cv::FeatureDetector
00010 {
00011   typedef cv::Ptr<cv::FeatureDetector> DetectorPtr;
00012   
00013   DetectorPtr active_detector_;
00014 
00015 public:
00016   AnyDetector(const DetectorPtr& detector = new cv::FastFeatureDetector)
00017     : active_detector_(detector)
00018   {
00019   }
00020 
00022   virtual void detect( const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints, const cv::Mat& mask=cv::Mat() ) const
00023   {
00024     detectImpl(image, keypoints, mask);
00025   }
00026 
00027   template <class Config>
00028   void update(Config& config)
00029   {
00030     if (config.detector == "FAST") {
00031       active_detector_ = new cv::FastFeatureDetector(config.fast_threshold, config.fast_nonmax_suppression);
00032     }
00033     else if (config.detector == "Harris") {
00034       active_detector_ = new cv::GoodFeaturesToTrackDetector(config.harris_max_keypoints, config.harris_quality_level,
00035                                                              config.harris_min_distance, config.harris_block_size,
00036                                                              true, config.harris_k);
00037     }
00038     else if (config.detector == "Star") {
00040       active_detector_ = new cv::StarFeatureDetector(config.star_max_size, config.star_response_threshold,
00041                                                      config.star_line_threshold_projected,
00042                                                      config.star_line_threshold_binarized,
00043                                                      config.star_suppress_nonmax_size);
00044     }
00045     else if (config.detector == "SURF") {
00046       active_detector_ = new cv::SurfFeatureDetector(config.surf_hessian_threshold, config.surf_octaves,
00047                                                      config.surf_octave_layers);
00048     }
00049     else
00050       ROS_ERROR("Unknown detector '%s'", config.detector.c_str());
00052 
00053     if (config.grid_adapter) {
00054       active_detector_ = new cv::GridAdaptedFeatureDetector(active_detector_, config.grid_max_keypoints,
00055                                                             config.grid_rows, config.grid_cols);
00056     }
00057   }
00058 
00059 protected:
00060   virtual void detectImpl( const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints, const cv::Mat& mask ) const
00061   {
00062     active_detector_->detect(image, keypoints, mask);
00063   }
00064 };
00065 
00066 } // namespace vslam_system
00067 
00068 #endif


vslam_system
Author(s): Kurt Konolige, Patrick Mihelich, Helen Oleynikova
autogenerated on Thu Jan 2 2014 12:12:31