GSoC2011SfM
0.1
Google Summer of Code 2011: Structure from motion
|
00001 #ifndef _GSOC_SFM_POINTSMATCHED_H 00002 #define _GSOC_SFM_POINTSMATCHED_H 1 00003 00004 #include "macro.h" //SFM_EXPORTS 00005 00006 #include "opencv2/features2d/features2d.hpp" 00007 #include <vector> 00008 00009 #include "config_SFM.h" //SEMAPHORE 00010 00011 namespace OpencvSfM{ 00012 class SFM_EXPORTS PointsToTrack; 00017 class SFM_EXPORTS PointsMatcher 00018 { 00019 public: 00024 PointsMatcher( const cv::Ptr<cv::DescriptorMatcher>& matcher ); 00025 00029 PointsMatcher( const PointsMatcher& copy ); 00033 virtual ~PointsMatcher( ); 00034 00041 static cv::Ptr<PointsMatcher> create( std::string match_algo ) 00042 { 00043 return cv::Ptr<PointsMatcher>( new PointsMatcher( 00044 cv::DescriptorMatcher::create( match_algo ) ) ); 00045 }; 00050 virtual void add( cv::Ptr<PointsToTrack> pointCollection ); 00054 virtual void clear( ); 00058 virtual void train( ); 00063 virtual bool isMaskSupported( ); 00068 virtual bool empty( ) const; 00074 virtual cv::Ptr<PointsMatcher> clone( bool emptyTrainData=true ); 00083 virtual void match( cv::Ptr<PointsToTrack> queryPoints, 00084 std::vector<cv::DMatch>& matches, 00085 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ) ); 00097 virtual void knnMatch( cv::Ptr<PointsToTrack> queryPoints, 00098 std::vector<std::vector<cv::DMatch> >& matches, int k, 00099 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ), bool compactResult = true ); 00110 virtual void radiusMatch( cv::Ptr<PointsToTrack> queryPoints,std::vector<std::vector<cv::DMatch> >& matches, float maxDistance, 00111 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ), bool compactResult = true ); 00120 virtual void crossMatch( cv::Ptr<PointsMatcher> otherMatcher, 00121 std::vector<cv::DMatch>& matches, 00122 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ) ); 00123 00145 static void drawMatches( const cv::Mat& img1, 00146 const std::vector<cv::KeyPoint>& keypoints1, 00147 const std::vector<cv::KeyPoint>& keypoints2, 00148 const std::vector<cv::DMatch>& matches1to2, cv::Mat& outImg, 00149 const cv::Scalar& matchColor=cv::Scalar::all( -1 ), 00150 const cv::Scalar& singlePointColor=cv::Scalar::all( -1 ), 00151 const std::vector<char>& matchesMask=std::vector<char>( ), 00152 int flags=cv::DrawMatchesFlags::DEFAULT 00153 ); 00154 00160 static void read( const cv::FileNode& node, PointsMatcher& points ); 00161 00167 static void write( cv::FileStorage& fs, const PointsMatcher& points ); 00168 00174 const cv::KeyPoint &getKeypoint( int numKey ) const; 00175 00176 protected: 00177 00182 DECLARE_MUTEX( thread_concurr ); 00183 00187 PointsMatcher(); 00188 00189 cv::Ptr<cv::DescriptorMatcher> matcher_; 00190 std::vector< cv::Ptr< PointsToTrack > > pointCollection_; 00191 }; 00192 00197 class SFM_EXPORTS PointsMatcherOpticalFlow : public PointsMatcher 00198 { 00207 int id_algo; 00208 double max_distance; 00209 public: 00221 PointsMatcherOpticalFlow( std::string name_of_algo, double dist_allowed = 2.0 ); 00222 00231 static cv::Ptr<PointsMatcher> create( std::string match_algo, double dist_allowed = 2.0 ) 00232 { 00233 return cv::Ptr<PointsMatcher>( new PointsMatcherOpticalFlow( 00234 match_algo, dist_allowed ) ); 00235 }; 00239 virtual void clear( ); 00243 virtual void train( ); 00248 virtual bool isMaskSupported( ); 00253 virtual bool empty( ) const; 00259 virtual cv::Ptr<PointsMatcher> clone( bool emptyTrainData=true ); 00268 virtual void match( cv::Ptr<PointsToTrack> queryPoints, 00269 std::vector<cv::DMatch>& matches, 00270 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ) ); 00282 virtual void knnMatch( cv::Ptr<PointsToTrack> queryPoints, 00283 std::vector<std::vector<cv::DMatch> >& matches, int k, 00284 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ), bool compactResult = true ); 00295 virtual void radiusMatch( cv::Ptr<PointsToTrack> queryPoints,std::vector<std::vector<cv::DMatch> >& matches, float maxDistance, 00296 const std::vector<cv::Mat>& masks = std::vector<cv::Mat>( ), bool compactResult = true ); 00297 }; 00298 00299 } 00300 00301 #endif