Created
February 21, 2014 19:00
-
-
Save lecram/9140902 to your computer and use it in GitHub Desktop.
Detecção e casamento de features com OpenCV.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* g++ -o keyp `pkg-config --libs opencv` keyp.cpp */ | |
#include <iostream> | |
#include <vector> | |
#include "opencv2/opencv.hpp" | |
using namespace std; | |
using namespace cv; | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 3) { | |
cout << "usage:" << endl << argv[0] << " image1 image2" << endl; | |
return 1; | |
} | |
Mat img1, img2, img3; | |
vector<KeyPoint> keyps1, keyps2; | |
Mat descs1, descs2; | |
vector<DMatch> matches; | |
Ptr<FeatureDetector> fd; | |
Ptr<DescriptorExtractor> de; | |
Ptr<DescriptorMatcher> dm; | |
img1 = imread(argv[1]); | |
img2 = imread(argv[2]); | |
//cvtColor(img1, img1, CV_BGR2GRAY); | |
//cvtColor(img2, img2, CV_BGR2GRAY); | |
// FAST, STAR, SIFT, SURF, ORB, BRISK, MSER, GFTT, HARRIS, Dense, SimpleBlob | |
fd = FeatureDetector::create("SIFT"); | |
fd->detect(img1, keyps1); | |
fd->detect(img2, keyps2); | |
// SIFT, SURF, BRIEF, BRISK, ORB, FREAK | |
de = DescriptorExtractor::create("SIFT"); | |
de->compute(img1, keyps1, descs1); | |
de->compute(img2, keyps2, descs2); | |
// BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-Hamming(2), FlannBased | |
dm = DescriptorMatcher::create("FlannBased"); | |
dm->match(descs1, descs2, matches); | |
cout << matches.size() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment