These days, we 've been stuck in the fast, surf, shift, brief, and ORB feature detection algorithms !!!
All labs are in the previous blog.
Opencv has already implemented them, so we will use opencv to test the effects of various methods,
My original intention was match. The feature points detected by fast could not be extracted from descriptor !!!
However, it is found that the keypoints detection and match process can be separated (although it may be meaningless, just try it)
1. Fast Detection Feature: fastfeaturedetector fast2 (40); // Threshold = 40
Fast1.detect (src1, keys1); // detect Feature Points
2. Match: Two Methods
2.1: surf Description: surfdescriptorextractor extractor;
Mat descriptors1, descriptors2;
Extractor. Compute (src1, keys1, descriptors1 );
Extractor. Compute (src2, keys2, descriptors2 );
Flannbasedmatcher; or bruteforcematcher <L2 <float> matcher;
Flannbasedmatcher;
Vector <dmatch> matches;
Matcher. Match (descriptors1, descriptors2, matches );
2.2: Brief Description: briefdescriptorextractor extractor;
+ Bruteforcematcher <Hamming> matcher;
3. drawmatches;
(For other methods such as ORB, feature extraction and description are directly completed in one step, and fast feature points cannot be brought into computing. This is also a kind of unintentional fun. Let's take a look)
# Include <opencv2/CORE/core. HPP> # include <opencv2/features2d/features2d. HPP> # include <opencv2/highgui. HPP> # include <vector> # include <iostream> using namespace CV; using namespace STD; char img_filename1 [] = "D:/src.jpg"; char img_filename2 [] = "D: /demo.jpg "; void main () {mat src1, src2; src1 = imread (img_filename1, 1); src2 = imread (img_filename2, 1 ); // vector of keypointsvector <keypoint> keys1; vector <keypoint> keys2; // construction of the fast Feature Detector objectfastfeaturedetector fast1 (40 ); // The detection threshold is 40 fastfeaturedetector fast2 (40); // feature point detectionfast1.detect (src1, keys1); Double T; t = gettickcount (); fast2.detect (src2, keys2 ); T = gettickcount ()-T; t = T * 1000/gettickfrequency (); cout <"keypoint size:" <keys2.size () <Endl; cout <"extract time:" <t <"Ms" <Endl; drawkeypoints (src1, keys1, src1, scalar: All (-1), drawmatchesflags :: draw_over_outimg); drawkeypoints (src2, keys2, src2, scalar: All (-1), drawmatchesflags: draw_over_outimg); imshow ("Fast feature1", src1 ); imshow ("Fast feature2", src2); cvwaitkey (0); t = gettickcount (); surfdescriptorextractor extractor; // run: bruteforcematcher <L2 <float> matcher // orb extractor; // not run; // writable extractor; // run: bruteforcematcher <Hamming> matchermat descriptors1, descriptors2; extractor. compute (src1, keys1, descriptors1); extractor. compute (src2, keys2, descriptors2); // bruteforcematcher <Hamming> matcher; // combine <L2 <float> matcher; flannbasedmatcher; vector <dmatch> matches; matcher. match (descriptors1, descriptors2, matches); t = gettickcount ()-T; t = T * 1000/gettickfrequency (); cout <"Match Time: "<t <" Ms "<Endl; MAT img_matches; drawmatches (src1, keys1, src2, keys2, matches, img_matches, scalar: All (-1 ), scalar: All (-1), vector <char> (), drawmatchesflags: not_draw_single_points); imshow ("Draw", img_matches); waitkey (0 );}
Messy fast + surf. descriptors + flannbasedmatcher; Result!