#pragma once #include "Utils/util.h" #include "featureMatch.h" #include "graphPro.h" #include #include #include #include #include "opencv2/nonfree/nonfree.hpp" #include #include #define Target_Octave 1 //! select subset of features for building similarity table using namespace std; using namespace cv; struct BiNode { int preNo; int curNo; }; struct Quadra { Point2d centroid; Size imgSize; // Point2d nodes[4]; Point2d RME; }; struct Keys { vector pts; Mat descriptors; }; // ============== NOTIFICATION =============== // //! node is encoded from 0, 2, ..., n-1. // //! cost graph: cost of non-overlap pair is -1 // // =========================================== // #define Load_Matches 0 //! just for debugging class TopoFinder { public: TopoFinder(PointMatcher *matcher) { _Ptmatcher = matcher; _imgNum = _Ptmatcher->_imgSizeList.size(); _shotNum = _attempNum = 0; _totalTime = _matchTime = 0; _isInOrder = false; }; ~TopoFinder(){}; public: //! return the topology depicted as a cost/weight table Mat_ findTopology(bool shallLoad, bool isInOrder); Mat_ loadSimilarityMat(); void saveSimilarityMat(const Mat_ &similarityMat); //! similarity value : number of matched features between image pair Mat_ detectSimilarityOnGlobal(); Mat_ detectSimilarityByGuiding(); void searchMainChain(); void buildMainChain(); //! detect potential overlaps and recalculate aligning model void detectPotentialOverlap(int curIndex, vector &pointSet1, vector &pointSet2); //! vocabulary tree -> association/guiding table Mat_ getGuidingTable(); //! not implemented Mat_ getGuidingTableP(); //! select features extracted from the top octave int findNodeIndex(int imgNo); //! X1 = Model * X2 Mat_ findFastAffine(vector pointSet1, vector pointSet2); void loadKeyFiles(); bool featureMatcher(int imgIndex1, int imgIndex2, vector &pointSet1, vector &pointSet2); int calSimilarNum(int imgIndex1, int imgIndex2); //! temperate functions void drawTopoNet(); Rect TsetImageSize(); void TsaveMosaicImage(); void drawTreeLevel(); private: int _imgNum; Mat_ _similarityMat; Mat_ _attempMap; //! only for unordered mode : 1 means attempted already bool _isInOrder; vector _visitOrder0; //! the alignment order vector > _affineMatList; //! same order with "_visitOrder0" vector > _covMatrixList; vector _projCoordSet; //! same order with "_visitOrder0" PointMatcher *_Ptmatcher; vector _keyList; //! same with image no. vector > _subKeyIndexList; //! subset for building similarity table //! variables for efficiency analysis int _attempNum, _shotNum; int _totalTime, _matchTime; };