|
|
|
@ -1,5 +1,8 @@ |
|
|
|
|
#include <cvaux.h> |
|
|
|
|
//#include <cvaux.h>
|
|
|
|
|
#include <highgui.h> |
|
|
|
|
#include "opencv2/core/core.hpp" |
|
|
|
|
#include "opencv2/calib3d/calib3d.hpp" |
|
|
|
|
#include "opencv2/imgproc/imgproc.hpp" |
|
|
|
|
#include "opencv2/features2d/features2d.hpp" |
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
|
@ -34,83 +37,6 @@ void warpPerspectiveRand( const Mat& src, Mat& dst, Mat& H, RNG* rng ) |
|
|
|
|
warpPerspective( src, dst, H, src.size() ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FeatureDetector* createDetector( const string& detectorType ) |
|
|
|
|
{ |
|
|
|
|
FeatureDetector* fd = 0; |
|
|
|
|
if( !detectorType.compare( "FAST" ) ) |
|
|
|
|
{ |
|
|
|
|
fd = new FastFeatureDetector( 10/*threshold*/, true/*nonmax_suppression*/ ); |
|
|
|
|
} |
|
|
|
|
else if( !detectorType.compare( "STAR" ) ) |
|
|
|
|
{ |
|
|
|
|
fd = new StarFeatureDetector( 16/*max_size*/, 5/*response_threshold*/, 10/*line_threshold_projected*/, |
|
|
|
|
8/*line_threshold_binarized*/, 5/*suppress_nonmax_size*/ ); |
|
|
|
|
} |
|
|
|
|
else if( !detectorType.compare( "SIFT" ) ) |
|
|
|
|
{ |
|
|
|
|
fd = new SiftFeatureDetector(SIFT::DetectorParams::GET_DEFAULT_THRESHOLD(), |
|
|
|
|
SIFT::DetectorParams::GET_DEFAULT_EDGE_THRESHOLD()); |
|
|
|
|
} |
|
|
|
|
else if( !detectorType.compare( "SURF" ) ) |
|
|
|
|
{ |
|
|
|
|
fd = new SurfFeatureDetector( 100./*hessian_threshold*/, 3 /*octaves*/, 4/*octave_layers*/ ); |
|
|
|
|
} |
|
|
|
|
else if( !detectorType.compare( "MSER" ) ) |
|
|
|
|
{ |
|
|
|
|
fd = new MserFeatureDetector( 5/*delta*/, 60/*min_area*/, 14400/*_max_area*/, 0.25f/*max_variation*/, |
|
|
|
|
0.2/*min_diversity*/, 200/*max_evolution*/, 1.01/*area_threshold*/, 0.003/*min_margin*/, |
|
|
|
|
5/*edge_blur_size*/ ); |
|
|
|
|
} |
|
|
|
|
else if( !detectorType.compare( "GFTT" ) ) |
|
|
|
|
{ |
|
|
|
|
fd = new GoodFeaturesToTrackDetector( 1000/*maxCorners*/, 0.01/*qualityLevel*/, 1./*minDistance*/, |
|
|
|
|
3/*int _blockSize*/, true/*useHarrisDetector*/, 0.04/*k*/ ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//CV_Error( CV_StsBadArg, "unsupported feature detector type");
|
|
|
|
|
} |
|
|
|
|
return fd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DescriptorExtractor* createDescriptorExtractor( const string& descriptorExtractorType ) |
|
|
|
|
{ |
|
|
|
|
DescriptorExtractor* de = 0; |
|
|
|
|
if( !descriptorExtractorType.compare( "SIFT" ) ) |
|
|
|
|
{ |
|
|
|
|
de = new SiftDescriptorExtractor/*( double magnification=SIFT::DescriptorParams::GET_DEFAULT_MAGNIFICATION(),
|
|
|
|
|
bool isNormalize=true, bool recalculateAngles=true, |
|
|
|
|
int nOctaves=SIFT::CommonParams::DEFAULT_NOCTAVES, |
|
|
|
|
int nOctaveLayers=SIFT::CommonParams::DEFAULT_NOCTAVE_LAYERS, |
|
|
|
|
int firstOctave=SIFT::CommonParams::DEFAULT_FIRST_OCTAVE, |
|
|
|
|
int angleMode=SIFT::CommonParams::FIRST_ANGLE )*/; |
|
|
|
|
} |
|
|
|
|
else if( !descriptorExtractorType.compare( "SURF" ) ) |
|
|
|
|
{ |
|
|
|
|
de = new SurfDescriptorExtractor/*( int nOctaves=4, int nOctaveLayers=2, bool extended=false )*/; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//CV_Error( CV_StsBadArg, "unsupported descriptor extractor type");
|
|
|
|
|
} |
|
|
|
|
return de; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DescriptorMatcher* createDescriptorMatcher( const string& descriptorMatcherType ) |
|
|
|
|
{ |
|
|
|
|
DescriptorMatcher* dm = 0; |
|
|
|
|
if( !descriptorMatcherType.compare( "BruteForce" ) ) |
|
|
|
|
{ |
|
|
|
|
dm = new BruteForceMatcher<L2<float> >(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//CV_Error( CV_StsBadArg, "unsupported descriptor matcher type");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return dm; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const string winName = "correspondences"; |
|
|
|
|
|
|
|
|
|
void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective, |
|
|
|
|