diff --git a/src/demo.cpp b/src/demo.cpp index b07ba9a..2a41818 100644 --- a/src/demo.cpp +++ b/src/demo.cpp @@ -1,39 +1,40 @@ /* - BRISK - Binary Robust Invariant Scalable Keypoints - Reference implementation of - [1] Stefan Leutenegger,Margarita Chli and Roland Siegwart, BRISK: - Binary Robust Invariant Scalable Keypoints, in Proceedings of - the IEEE International Conference on Computer Vision (ICCV2011). - - Copyright (C) 2011 The Autonomous Systems Lab (ASL), ETH Zurich, - Stefan Leutenegger, Simon Lynen and Margarita Chli. - - This file is part of BRISK. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the ASL nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + BRISK - Binary Robust Invariant Scalable Keypoints + Reference implementation of + [1] Stefan Leutenegger,Margarita Chli and Roland Siegwart, BRISK: + Binary Robust Invariant Scalable Keypoints, in Proceedings of + the IEEE International Conference on Computer Vision (ICCV2011). + + Copyright (C) 2011 The Autonomous Systems Lab (ASL), ETH Zurich, + Stefan Leutenegger, Simon Lynen and Margarita Chli. + + This file is part of BRISK. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the ASL nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include +#include #include "../include/brisk/brisk.h" #include #include @@ -45,32 +46,32 @@ const float r=2.5; // found 8-9-11, r=3.6, exponent 1.5 void help(char** argv){ std::cout << "This command line tool lets you evaluate different keypoint " - << "detectors, descriptors and matchers." << std::endl - << "usage:" << std::endl - << argv[0] << " <2nd> [descFile1 descFile1]" << std::endl - << " " << "dataset: Folder containing the images. The images must be of .ppm "<< std::endl - << " " << " format. They must be named img#.ppm, and there must be "<< std::endl - << " " << " corresponding homographies named H1to#." << std::endl - << " " << " You can also use the prefix rot-, then 2nd will be the" << std::endl - << " " << " rotation in degrees." << std::endl - << " " << "2nd: Number of the 2nd image (the 1st one is always img1.ppm)"<< std::endl - << " " << " or the rotation in degrees, if rot- used." << std::endl - << " " << "detector: Feature detector, e.g. AGAST, or BRISK. You can add the "<< std::endl - << " " << " threshold, e.g. BRISK80 or SURF2000"<< std::endl - << " " << "descriptor: Feature descriptor, e.g. SURF, BRIEF, BRISK or U-BRISK."<< std::endl - << " " << "[descFile]: Optional: files with descriptors to act as detected points."<< std::endl; + << "detectors, descriptors and matchers." << std::endl + << "usage:" << std::endl + << argv[0] << " <2nd> [descFile1 descFile1]" << std::endl + << " " << "dataset: Folder containing the images. The images must be of .ppm "<< std::endl + << " " << " format. They must be named img#.ppm, and there must be "<< std::endl + << " " << " corresponding homographies named H1to#." << std::endl + << " " << " You can also use the prefix rot-, then 2nd will be the" << std::endl + << " " << " rotation in degrees." << std::endl + << " " << "2nd: Number of the 2nd image (the 1st one is always img1.ppm)"<< std::endl + << " " << " or the rotation in degrees, if rot- used." << std::endl + << " " << "detector: Feature detector, e.g. AGAST, or BRISK. You can add the "<< std::endl + << " " << " threshold, e.g. BRISK80 or SURF2000"<< std::endl + << " " << "descriptor: Feature descriptor, e.g. SURF, BRIEF, BRISK or U-BRISK."<< std::endl + << " " << "[descFile]: Optional: files with descriptors to act as detected points."<< std::endl; } int main(int argc, char ** argv) { - + //std::cout< keypoints, keypoints2; int threshold; - + // create the detector: cv::Ptr detector; if(argc==1){ @@ -179,7 +180,7 @@ int main(int argc, char ** argv) { threshold = atoi(argv[3]+4); if(threshold==0) threshold = 30; - detector = new cv::FastFeatureDetector(threshold,true); + detector = cv::FastFeatureDetector::create(threshold,true); } else if(strncmp("AGAST", argv[3], 5 )==0){ threshold = atoi(argv[3]+5); @@ -196,25 +197,25 @@ int main(int argc, char ** argv) { /*else if(strncmp("SURF", argv[3], 4 )==0){ threshold = atoi(argv[3]+4); if(threshold==0) - threshold = 400; + threshold = 400; detector = new cv::SurfFeatureDetector(threshold); - } - else if(strncmp("SIFT", argv[3], 4 )==0){ + } + else if(strncmp("SIFT", argv[3], 4 )==0){ float thresh = 0.04 / cv::SIFT::CommonParams::DEFAULT_NOCTAVE_LAYERS / 2.0; float edgeThreshold=atof(argv[3]+4); if(edgeThreshold==0) - thresh = 10.0; + thresh = 10.0; detector = new cv::SiftFeatureDetector(thresh,edgeThreshold); - }*/ - else{ + } + else{ detector = cv::FeatureDetector::create( argv[3] ); - } + }*/ if (detector.empty()){ std::cout << "Detector " << argv[3] << " not recognized. Check spelling!" << std::endl; return 3; } } - + // run the detector: if(argc == 7){ // try to read descriptor files @@ -230,7 +231,7 @@ int main(int argc, char ** argv) { std::cout<<"Descriptor file not found at " << desc2<detect(imgGray1,keypoints); detector->detect(imgGray2,keypoints2); } - + // now the extractor: bool hamming=true; cv::Ptr descriptorExtractor; @@ -292,30 +293,30 @@ int main(int argc, char ** argv) { descriptorExtractor = new brisk::BriskDescriptorExtractor(true,false); } else if(std::string(argv[4])=="BRIEF"){ - descriptorExtractor = new cv::BriefDescriptorExtractor(64); + descriptorExtractor = cv::xfeatures2d::BriefDescriptorExtractor::create(64); } /*else if(std::string(argv[4])=="CALONDER"){ descriptorExtractor = new cv::CalonderDescriptorExtractor("current.rtc"); hamming=false; - } - else if(std::string(argv[4])=="SURF"){ + } + else if(std::string(argv[4])=="SURF"){ descriptorExtractor = new cv::SurfDescriptorExtractor(); hamming=false; - } - else if(std::string(argv[4])=="SIFT"){ + } + else if(std::string(argv[4])=="SIFT"){ descriptorExtractor = new cv::SiftDescriptorExtractor(); hamming=false; - }*/ - else{ + } + else{ descriptorExtractor = cv::DescriptorExtractor::create( argv[4] ); - } + }*/ if (descriptorExtractor.empty()){ hamming=false; std::cout << "Descriptor " << argv[4] << " not recognized. Check spelling!" << std::endl; return 4; } } - + // get the descriptors cv::Mat descriptors, descriptors2; std::vector indices; @@ -323,13 +324,13 @@ int main(int argc, char ** argv) { descriptorExtractor->compute(imgGray2,keypoints2,descriptors2); // and the second one descriptorExtractor->compute(imgGray1,keypoints,descriptors); - + // matching std::vector > matches; cv::Ptr descriptorMatcher; if(hamming) //descriptorMatcher = new cv::BruteForceMatcher(); - descriptorMatcher = new cv::BFMatcher(cv::NORM_HAMMING); + descriptorMatcher = new cv::BFMatcher(cv::NORM_HAMMING); else descriptorMatcher = new cv::BFMatcher(); if(hamming) @@ -337,14 +338,14 @@ int main(int argc, char ** argv) { else descriptorMatcher->radiusMatch(descriptors2,descriptors,matches,0.21); cv::Mat outimg; - + // drawing drawMatches(imgRGB2, keypoints2, imgRGB1, keypoints,matches,outimg, cv::Scalar(0,255,0), cv::Scalar(0,0,255), - std::vector >(), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS ); + std::vector >(), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS ); cv::namedWindow("Matches"); cv::imshow("Matches", outimg); cv::waitKey(); - + return 0; }