added initModule_features2d(). Possibly solved problem when the linker excludes seemingly unused detectors/descriptors.
This commit is contained in:
parent
c7d38a3aab
commit
a3262c5e51
@ -51,6 +51,8 @@
|
|||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CV_EXPORTS bool initModule_features2d();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
The Keypoint Class
|
The Keypoint Class
|
||||||
|
@ -172,20 +172,4 @@ void BriefDescriptorExtractor::computeImpl(const Mat& image, std::vector<KeyPoin
|
|||||||
test_fn_(sum, keypoints, descriptors);
|
test_fn_(sum, keypoints, descriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Algorithm* createBRIEF() { return new BriefDescriptorExtractor; }
|
|
||||||
static AlgorithmInfo brief_info("Feature2D.BRIEF", createBRIEF);
|
|
||||||
|
|
||||||
AlgorithmInfo* BriefDescriptorExtractor::info() const
|
|
||||||
{
|
|
||||||
static volatile bool initialized = false;
|
|
||||||
if( !initialized )
|
|
||||||
{
|
|
||||||
BriefDescriptorExtractor brief;
|
|
||||||
brief_info.addParam(brief, "bytes", brief.bytes_);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return &brief_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
@ -359,5 +359,131 @@ void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, vector<KeyPoin
|
|||||||
if( !mask.empty() )
|
if( !mask.empty() )
|
||||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////// AlgorithmInfo for various detector & descriptors ////////////////////////////
|
||||||
|
|
||||||
|
/* NOTE!!!
|
||||||
|
All the AlgorithmInfo-related stuff should be in the same file as initModule_features2d().
|
||||||
|
Otherwise, linker may throw away some seemingly unused stuff.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static Algorithm* createBRIEF() { return new BriefDescriptorExtractor; }
|
||||||
|
static AlgorithmInfo brief_info("Feature2D.BRIEF", createBRIEF);
|
||||||
|
|
||||||
|
AlgorithmInfo* BriefDescriptorExtractor::info() const
|
||||||
|
{
|
||||||
|
static volatile bool initialized = false;
|
||||||
|
if( !initialized )
|
||||||
|
{
|
||||||
|
BriefDescriptorExtractor brief;
|
||||||
|
brief_info.addParam(brief, "bytes", brief.bytes_);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
return &brief_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static Algorithm* createFAST() { return new FastFeatureDetector; }
|
||||||
|
static AlgorithmInfo fast_info("Feature2D.FAST", createFAST);
|
||||||
|
|
||||||
|
AlgorithmInfo* FastFeatureDetector::info() const
|
||||||
|
{
|
||||||
|
static volatile bool initialized = false;
|
||||||
|
if( !initialized )
|
||||||
|
{
|
||||||
|
FastFeatureDetector obj;
|
||||||
|
fast_info.addParam(obj, "threshold", obj.threshold);
|
||||||
|
fast_info.addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
return &fast_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static Algorithm* createStarDetector() { return new StarDetector; }
|
||||||
|
static AlgorithmInfo star_info("Feature2D.STAR", createStarDetector);
|
||||||
|
|
||||||
|
AlgorithmInfo* StarDetector::info() const
|
||||||
|
{
|
||||||
|
static volatile bool initialized = false;
|
||||||
|
if( !initialized )
|
||||||
|
{
|
||||||
|
StarDetector obj;
|
||||||
|
star_info.addParam(obj, "maxSize", obj.maxSize);
|
||||||
|
star_info.addParam(obj, "responseThreshold", obj.responseThreshold);
|
||||||
|
star_info.addParam(obj, "lineThresholdProjected", obj.lineThresholdProjected);
|
||||||
|
star_info.addParam(obj, "lineThresholdBinarized", obj.lineThresholdBinarized);
|
||||||
|
star_info.addParam(obj, "suppressNonmaxSize", obj.suppressNonmaxSize);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
return &star_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static Algorithm* createMSER() { return new MSER; }
|
||||||
|
static AlgorithmInfo mser_info("Feature2D.MSER", createMSER);
|
||||||
|
|
||||||
|
AlgorithmInfo* MSER::info() const
|
||||||
|
{
|
||||||
|
static volatile bool initialized = false;
|
||||||
|
if( !initialized )
|
||||||
|
{
|
||||||
|
MSER obj;
|
||||||
|
mser_info.addParam(obj, "delta", obj.delta);
|
||||||
|
mser_info.addParam(obj, "minArea", obj.minArea);
|
||||||
|
mser_info.addParam(obj, "maxArea", obj.maxArea);
|
||||||
|
mser_info.addParam(obj, "maxVariation", obj.maxVariation);
|
||||||
|
mser_info.addParam(obj, "minDiversity", obj.minDiversity);
|
||||||
|
mser_info.addParam(obj, "maxEvolution", obj.maxEvolution);
|
||||||
|
mser_info.addParam(obj, "areaThreshold", obj.areaThreshold);
|
||||||
|
mser_info.addParam(obj, "minMargin", obj.minMargin);
|
||||||
|
mser_info.addParam(obj, "edgeBlurSize", obj.edgeBlurSize);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
return &mser_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static Algorithm* createORB() { return new ORB; }
|
||||||
|
static AlgorithmInfo orb_info("Feature2D.ORB", createORB);
|
||||||
|
|
||||||
|
AlgorithmInfo* ORB::info() const
|
||||||
|
{
|
||||||
|
static volatile bool initialized = false;
|
||||||
|
if( !initialized )
|
||||||
|
{
|
||||||
|
ORB obj;
|
||||||
|
orb_info.addParam(obj, "nFeatures", obj.nfeatures);
|
||||||
|
orb_info.addParam(obj, "scaleFactor", obj.scaleFactor);
|
||||||
|
orb_info.addParam(obj, "nLevels", obj.nlevels);
|
||||||
|
orb_info.addParam(obj, "firstLevel", obj.firstLevel);
|
||||||
|
orb_info.addParam(obj, "edgeThreshold", obj.edgeThreshold);
|
||||||
|
orb_info.addParam(obj, "patchSize", obj.patchSize);
|
||||||
|
orb_info.addParam(obj, "WTA_K", obj.WTA_K);
|
||||||
|
orb_info.addParam(obj, "scoreType", obj.scoreType);
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
return &orb_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool initModule_features2d(void)
|
||||||
|
{
|
||||||
|
Ptr<Algorithm> brief = createBRIEF(), orb = createORB(),
|
||||||
|
star = createStarDetector(), fastd = createFAST(), mser = createMSER();
|
||||||
|
return brief->info() != 0 && orb->info() != 0 && star->info() != 0 &&
|
||||||
|
fastd->info() != 0 && mser->info() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -391,22 +391,4 @@ void FastFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoi
|
|||||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Algorithm* createFAST() { return new FastFeatureDetector; }
|
|
||||||
static AlgorithmInfo fast_info("Feature2D.FAST", createFAST);
|
|
||||||
|
|
||||||
AlgorithmInfo* FastFeatureDetector::info() const
|
|
||||||
{
|
|
||||||
static volatile bool initialized = false;
|
|
||||||
if( !initialized )
|
|
||||||
{
|
|
||||||
FastFeatureDetector obj;
|
|
||||||
fast_info.addParam(obj, "threshold", obj.threshold);
|
|
||||||
fast_info.addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return &fast_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1299,28 +1299,4 @@ void MserFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Algorithm* createMSER() { return new MSER; }
|
|
||||||
static AlgorithmInfo mser_info("Feature2D.MSER", createMSER);
|
|
||||||
|
|
||||||
AlgorithmInfo* MSER::info() const
|
|
||||||
{
|
|
||||||
static volatile bool initialized = false;
|
|
||||||
if( !initialized )
|
|
||||||
{
|
|
||||||
MSER obj;
|
|
||||||
mser_info.addParam(obj, "delta", obj.delta);
|
|
||||||
mser_info.addParam(obj, "minArea", obj.minArea);
|
|
||||||
mser_info.addParam(obj, "maxArea", obj.maxArea);
|
|
||||||
mser_info.addParam(obj, "maxVariation", obj.maxVariation);
|
|
||||||
mser_info.addParam(obj, "minDiversity", obj.minDiversity);
|
|
||||||
mser_info.addParam(obj, "maxEvolution", obj.maxEvolution);
|
|
||||||
mser_info.addParam(obj, "areaThreshold", obj.areaThreshold);
|
|
||||||
mser_info.addParam(obj, "minMargin", obj.minMargin);
|
|
||||||
mser_info.addParam(obj, "edgeBlurSize", obj.edgeBlurSize);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return &mser_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -546,31 +546,6 @@ static void makeRandomPattern(int patchSize, Point* pattern, int npoints)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static Algorithm* createORB() { return new ORB; }
|
|
||||||
static AlgorithmInfo orb_info("Feature2D.ORB", createORB);
|
|
||||||
|
|
||||||
AlgorithmInfo* ORB::info() const
|
|
||||||
{
|
|
||||||
static volatile bool initialized = false;
|
|
||||||
if( !initialized )
|
|
||||||
{
|
|
||||||
ORB obj;
|
|
||||||
orb_info.addParam(obj, "nFeatures", obj.nfeatures);
|
|
||||||
orb_info.addParam(obj, "scaleFactor", obj.scaleFactor);
|
|
||||||
orb_info.addParam(obj, "nLevels", obj.nlevels);
|
|
||||||
orb_info.addParam(obj, "firstLevel", obj.firstLevel);
|
|
||||||
orb_info.addParam(obj, "edgeThreshold", obj.edgeThreshold);
|
|
||||||
orb_info.addParam(obj, "patchSize", obj.patchSize);
|
|
||||||
orb_info.addParam(obj, "WTA_K", obj.WTA_K);
|
|
||||||
orb_info.addParam(obj, "scoreType", obj.scoreType);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return &orb_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float getScale(int level, int firstLevel, double scaleFactor)
|
static inline float getScale(int level, int firstLevel, double scaleFactor)
|
||||||
{
|
{
|
||||||
return (float)std::pow(scaleFactor, (double)(level - firstLevel));
|
return (float)std::pow(scaleFactor, (double)(level - firstLevel));
|
||||||
|
@ -447,25 +447,4 @@ void StarDetector::operator()(const Mat& img, vector<KeyPoint>& keypoints) const
|
|||||||
lineThresholdBinarized, suppressNonmaxSize );
|
lineThresholdBinarized, suppressNonmaxSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Algorithm* createStarDetector() { return new StarDetector; }
|
|
||||||
static AlgorithmInfo star_info("Feature2D.STAR", createStarDetector);
|
|
||||||
|
|
||||||
AlgorithmInfo* StarDetector::info() const
|
|
||||||
{
|
|
||||||
static volatile bool initialized = false;
|
|
||||||
if( !initialized )
|
|
||||||
{
|
|
||||||
StarDetector obj;
|
|
||||||
star_info.addParam(obj, "maxSize", obj.maxSize);
|
|
||||||
star_info.addParam(obj, "responseThreshold", obj.responseThreshold);
|
|
||||||
star_info.addParam(obj, "lineThresholdProjected", obj.lineThresholdProjected);
|
|
||||||
star_info.addParam(obj, "lineThresholdBinarized", obj.lineThresholdBinarized);
|
|
||||||
star_info.addParam(obj, "suppressNonmaxSize", obj.suppressNonmaxSize);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return &star_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -672,29 +672,6 @@ int SIFT::descriptorType() const
|
|||||||
return CV_32F;
|
return CV_32F;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Algorithm* createSIFT()
|
|
||||||
{
|
|
||||||
return new SIFT;
|
|
||||||
}
|
|
||||||
static AlgorithmInfo sift_info("Feature2D.SIFT", createSIFT);
|
|
||||||
|
|
||||||
AlgorithmInfo* SIFT::info() const
|
|
||||||
{
|
|
||||||
static volatile bool initialized = false;
|
|
||||||
if( !initialized )
|
|
||||||
{
|
|
||||||
SIFT obj;
|
|
||||||
sift_info.addParam(obj, "nFeatures", obj.nfeatures);
|
|
||||||
sift_info.addParam(obj, "nOctaveLayers", obj.nOctaveLayers);
|
|
||||||
sift_info.addParam(obj, "contrastThreshold", obj.contrastThreshold);
|
|
||||||
sift_info.addParam(obj, "edgeThreshold", obj.edgeThreshold);
|
|
||||||
sift_info.addParam(obj, "sigma", obj.sigma);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
return &sift_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SIFT::operator()(InputArray _image, InputArray _mask,
|
void SIFT::operator()(InputArray _image, InputArray _mask,
|
||||||
vector<KeyPoint>& keypoints) const
|
vector<KeyPoint>& keypoints) const
|
||||||
|
@ -109,8 +109,6 @@ Modifications by Ian Mahon
|
|||||||
*/
|
*/
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
bool cv::initModule_nonfree(void) { return true; }
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -927,6 +925,9 @@ void SURF::computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& desc
|
|||||||
(*this)(image, Mat(), keypoints, descriptors, true);
|
(*this)(image, Mat(), keypoints, descriptors, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static Algorithm* createSURF()
|
static Algorithm* createSURF()
|
||||||
{
|
{
|
||||||
return new SURF;
|
return new SURF;
|
||||||
@ -949,43 +950,38 @@ AlgorithmInfo* SURF::info() const
|
|||||||
}
|
}
|
||||||
return &surf_info;
|
return &surf_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// SurfFeatureDetector
|
static Algorithm* createSIFT()
|
||||||
SurfFeatureDetector::SurfFeatureDetector( double hessianThreshold, int octaves, int octaveLayers, bool upright )
|
{
|
||||||
: surf(hessianThreshold, octaves, octaveLayers, false, upright)
|
return new SIFT;
|
||||||
{}
|
}
|
||||||
|
static AlgorithmInfo sift_info("Feature2D.SIFT", createSIFT);
|
||||||
void SurfFeatureDetector::read (const FileNode& fn)
|
|
||||||
{
|
AlgorithmInfo* SIFT::info() const
|
||||||
double hessianThreshold = fn["hessianThreshold"];
|
{
|
||||||
int octaves = fn["octaves"];
|
static volatile bool initialized = false;
|
||||||
int octaveLayers = fn["octaveLayers"];
|
if( !initialized )
|
||||||
bool upright = (int)fn["upright"] != 0;
|
{
|
||||||
|
SIFT obj;
|
||||||
surf = SURF( hessianThreshold, octaves, octaveLayers, false, upright );
|
sift_info.addParam(obj, "nFeatures", obj.nfeatures);
|
||||||
}
|
sift_info.addParam(obj, "nOctaveLayers", obj.nOctaveLayers);
|
||||||
|
sift_info.addParam(obj, "contrastThreshold", obj.contrastThreshold);
|
||||||
void SurfFeatureDetector::write (FileStorage& fs) const
|
sift_info.addParam(obj, "edgeThreshold", obj.edgeThreshold);
|
||||||
{
|
sift_info.addParam(obj, "sigma", obj.sigma);
|
||||||
//fs << "algorithm" << getAlgorithmName ();
|
|
||||||
|
initialized = true;
|
||||||
fs << "hessianThreshold" << surf.hessianThreshold;
|
}
|
||||||
fs << "octaves" << surf.nOctaves;
|
return &sift_info;
|
||||||
fs << "octaveLayers" << surf.nOctaveLayers;
|
}
|
||||||
fs << "upright" << surf.upright;
|
|
||||||
}
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void SurfFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
bool initModule_nonfree(void)
|
||||||
{
|
{
|
||||||
Mat grayImage = image;
|
Ptr<Algorithm> sift = createSIFT(), surf = createSURF();
|
||||||
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
return sift->info() != 0 && surf->info() != 0;
|
||||||
|
}
|
||||||
surf(grayImage, mask, keypoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user