From: Gary Bradski Date: Wed, 24 Nov 2010 02:35:10 +0000 (+0000) Subject: Docs for using BRIEF in features2d X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~8348 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b769639f1bd7dd9a871ed126cd225a8ed60835ea;p=platform%2Fupstream%2Fopencv.git Docs for using BRIEF in features2d --- diff --git a/samples/cpp/brief_match_test.cpp b/samples/cpp/brief_match_test.cpp index 81f517d..68013f4 100644 --- a/samples/cpp/brief_match_test.cpp +++ b/samples/cpp/brief_match_test.cpp @@ -15,6 +15,16 @@ using std::cerr; using std::endl; using std::vector; +void help(char **av) +{ + cerr << "usage: " << av[0] << " im1.jpg im2.jpg" + << "\n" + << "This program shows how to use brief to match points in features2d\n" + << "It takes in two images, finds keypoints and matches them displaying matches and final homography warped results\n" + << endl; +} + +//Copy (x,y) location of descriptor matches found from KeyPoint data structures into Point2f vectors void matches2points(const vector& matches, const vector& kpts_train, const vector& kpts_query, vector& pts_train, vector& pts_query) { @@ -36,15 +46,17 @@ float match(const vector& kpts_train, const vector& kpts_que { float t = (double)getTickCount(); - matcher.match(query, train, matches); + matcher.match(query, train, matches); //Using features2d return ((double)getTickCount() - t) / getTickFrequency(); } + + int main(int ac, char ** av) { if (ac != 3) { - cerr << "usage: " << av[0] << " im1.jpg im2.jpg" << endl; + help(av); return 1; } string im1_name, im2_name; @@ -63,7 +75,7 @@ int main(int ac, char ** av) double t = (double)getTickCount(); FastFeatureDetector detector(50); - BriefDescriptorExtractor extractor(32); + BriefDescriptorExtractor extractor(32); //this is really 32 x 8 matches since they are binary matches packed into bytes vector kpts_1, kpts_2; detector.detect(im1, kpts_1); @@ -87,6 +99,7 @@ int main(int ac, char ** av) cout << "done computing descriptors... took " << t << " seconds" << endl; + //Do matching with 2 methods using features2d cout << "matching with BruteForceMatcher" << endl; BruteForceMatcher matcher; vector matches_lut; @@ -100,7 +113,7 @@ int main(int ac, char ** av) cout << "done BruteForceMatcher matching. took " << pop_time << " seconds" << endl; vector mpts_1, mpts_2; - matches2points(matches_popcount, kpts_1, kpts_2, mpts_1, mpts_2); + matches2points(matches_popcount, kpts_1, kpts_2, mpts_1, mpts_2); //Extract a list of the (x,y) location of the matches vector outlier_mask; Mat H = findHomography(Mat(mpts_2), Mat(mpts_1), outlier_mask, RANSAC, 1);