Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SURFDetector.hpp
00001 /* $Id$ */
00002 
00003 #ifndef _FDETECT_SURF_DETECTOR_HPP_
00004 #define _FDETECT_SURF_DETECTOR_HPP_
00005 
00006 #include <vector>
00007 
00008 #include <boost/archive/text_oarchive.hpp>
00009 #include <boost/archive/text_iarchive.hpp>
00010 
00011 #include "fdetect/Detector.hpp"
00012 #include "fdetect/FloatDescriptor.hpp"
00013 #include "fdetect/RealDescriptor.hpp"
00014 
00015 #include <opencv/cxcore.h>
00016 #if CV_MAJOR_VERSION*10 + CV_MINOR_VERSION > 21
00017 #include <opencv2/features2d/features2d.hpp>
00018 #else
00019 #include <cv.h>
00020 #include <cv.hpp>
00021 #endif
00022 
00023 namespace jafar {
00024   namespace fdetect {
00029     class SURFDetector : public fdetect::Detector {
00030     private:
00032       cv::SURF cv_surf;
00034       std::vector<cv::KeyPoint> cv_keypoints;
00036       std::vector<float> cv_descriptors;
00038       friend class boost::serialization::access;
00039       template<class Archive>
00040       void serialize(Archive & ar, const unsigned int /* file_version */){
00041   ar & cv_surf.hessianThreshold;
00042   ar & cv_surf.extended;
00043   ar & cv_surf.nOctaves;
00044   ar & cv_surf.nOctaveLayers;
00045       }
00046       
00047     public:
00056       SURFDetector(double _hessianThreshold = 500, int _nOctaves=4,
00057        int _nOctaveLayers=2, bool _extended=false);
00059       bool extended() const;
00061       double hessianThreshold() const;
00063       int octaves() const;
00065       int octaveLayers() const;
00067       void setExtended(bool _extended);
00069       void setHessianThreshold(double _hessianThreshold);
00071       void setOctaves(int _nOctave);
00073       void setOctaveLayers(int _nOctaveLayers);
00074       
00075       virtual fdetect::DetectionResult detectIn(jafar::image::Image const& image);
00076     };
00077   }
00078 #ifndef SWIG
00079   namespace fdetect_v2 {
00084     template< typename InterestFeatureT >
00085     class SURFDetectorT : public fdetect_v2::Detector< InterestFeatureT >
00086     {
00087     private:
00089       cv::SURF cv_surf;
00091       friend class boost::serialization::access;
00092       template<class Archive>
00093       void serialize(Archive & ar, const unsigned int /* file_version */){
00094         ar & cv_surf.hessianThreshold;
00095         ar & cv_surf.extended;
00096         ar & cv_surf.nOctaves;
00097         ar & cv_surf.nOctaveLayers;
00098       }
00099       
00100     public:
00101       typedef InterestFeatureT InterestFeatureType;
00102       typedef fdetect_v2::DetectionResult<InterestFeatureT> DetectionResult;
00111       SURFDetectorT(double _hessianThreshold = 500, int _nOctaves=4,
00112                    int _nOctaveLayers=2, bool _extended=false)
00113       {
00114         cv_surf.hessianThreshold = _hessianThreshold;
00115         cv_surf.extended = _extended;
00116         cv_surf.nOctaves = _nOctaves;
00117         cv_surf.nOctaveLayers = _nOctaveLayers;
00118       }
00119       ~SURFDetectorT() {}
00121       bool extended() const;
00123       double hessianThreshold() const;
00125       int octaves() const;
00127       int octaveLayers() const;
00129       void setExtended(bool _extended);
00131       void setHessianThreshold(double _hessianThreshold);
00133       void setOctaves(int _nOctave);
00135       void setOctaveLayers(int _nOctaveLayers);
00140       virtual DetectionResult detectIn(jafar::image::Image const& image) {
00141         return detectIn(image, jafar::image::Image(), true);
00142       }
00148       DetectionResult detectIn(jafar::image::Image const& image,
00149                                const jafar::image::Image& mask,
00150                                bool with_descriptors);
00154       void computeDescriptors(jafar::image::Image const& image, 
00155                               DetectionResult& dr) 
00156       {
00157         computeDescriptors(image, jafar::image::Image(), dr);
00158       }
00162       void computeDescriptors(jafar::image::Image const& image, 
00163                               const jafar::image::Image& mask,
00164                               DetectionResult& dr);
00165     };
00167     typedef SURFDetectorT<fdetect_v2::InterestFeature<fdetect_v2::FloatDescriptor> > SURFDetector;
00168   }
00169 #endif
00170 }
00171 #include "fdetect/SURFDetector.hxx"
00172 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:19 for Jafar by doxygen 1.7.6.1
LAAS-CNRS