TEST_F(MatcherGTest, testPgaMatching) { count n = 50; Graph G(n); G.forNodePairs([&](node u, node v){ G.addEdge(u,v); }); PathGrowingMatcher pgaMatcher(G); DEBUG("Start PGA matching on 50-clique"); pgaMatcher.run(); Matching M = pgaMatcher.getMatching(); count numExpEdges = n / 2; bool isProper = M.isProper(G); EXPECT_TRUE(isProper); EXPECT_EQ(M.size(G), numExpEdges); DEBUG("Finished PGA matching on 50-clique"); #if !defined _WIN32 && !defined _WIN64 && !defined WIN32 && !defined WIN64 DibapGraphReader reader; Graph airfoil1 = reader.read("input/airfoil1.gi"); PathGrowingMatcher pga2(airfoil1); pga2.run(); M = pga2.getMatching(); isProper = M.isProper(airfoil1); EXPECT_TRUE(isProper); DEBUG("PGA on airfoil1 produces matching of size: " , M.size(G)); #endif }
TEST_F(MatcherGTest, testLocalMaxMatching) { count n = 50; Graph G(n); G.forNodePairs([&](node u, node v){ G.addEdge(u,v); }); LocalMaxMatcher localMaxMatcher(G); TRACE("Start localMax matching"); localMaxMatcher.run(); Matching M = localMaxMatcher.getMatching(); TRACE("Finished localMax matching"); count numExpEdges = n / 2; bool isProper = M.isProper(G); EXPECT_TRUE(isProper); EXPECT_EQ(M.size(G), numExpEdges); #if !defined _WIN32 && !defined _WIN64 && !defined WIN32 && !defined WIN64 DibapGraphReader reader; Graph airfoil1 = reader.read("input/airfoil1.gi"); LocalMaxMatcher lmm(airfoil1); lmm.run(); M = lmm.getMatching(); isProper = M.isProper(airfoil1); EXPECT_TRUE(isProper); DEBUG("LocalMax on airfoil1 produces matching of size: " , M.size(G)); #endif }
void GetAlignedPointsFromMatch(const Features& leftFeatures, const Features& rightFeatures, const Matching& matches, Features& alignedLeft, Features& alignedRight, vector<int>& leftBackReference, vector<int>& rightBackReference) { alignedLeft .keyPoints.clear(); alignedRight.keyPoints.clear(); alignedLeft .descriptors = cv::Mat(); alignedRight.descriptors = cv::Mat(); for (unsigned int i=0; i<matches.size(); i++) { alignedLeft .keyPoints .push_back(leftFeatures.keyPoints [matches[i].queryIdx]); alignedLeft .descriptors.push_back(leftFeatures.descriptors.row (matches[i].queryIdx)); alignedRight.keyPoints .push_back(rightFeatures.keyPoints [matches[i].trainIdx]); alignedRight.descriptors.push_back(rightFeatures.descriptors.row(matches[i].trainIdx)); leftBackReference .push_back(matches[i].queryIdx); rightBackReference.push_back(matches[i].trainIdx); } KeyPointsToPoints(alignedLeft.keyPoints, alignedLeft.points); KeyPointsToPoints(alignedRight.keyPoints, alignedRight.points); }
void verifyMatching(BipartiteGraph g, unsigned expectedSize) { Matching matching = findMaximumMatching(g); typedef boost::unordered_set<unsigned> VertexSet; VertexSet first; VertexSet second; for (auto elem : matching) { ASSERT_TRUE(first.insert(elem.first).second); ASSERT_TRUE(second.insert(elem.second).second); ASSERT_TRUE(g.edgeExists(elem)); } ASSERT_EQ(expectedSize, matching.size()); }