diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 81990c9e0..dfb807ca2 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -4294,8 +4294,8 @@ public: ~AlgorithmInfo(); void get(const Algorithm* algo, const char* name, int argType, void* value) const; void set(Algorithm* algo, const char* name, int argType, const void* value) const; - void addParam_(const Algorithm* algo, const char* name, int argType, - const void* value, bool readOnly, + void addParam_(Algorithm& algo, const char* name, int argType, + void* value, bool readOnly, Algorithm::Getter getter, Algorithm::Setter setter, const string& help=string()); string paramHelp(const char* name) const; @@ -4306,33 +4306,33 @@ public: void read(Algorithm* algo, const FileNode& fn) const; string name() const; - void addParam(const Algorithm* algo, const char* name, - const int& value, bool readOnly=false, + void addParam(Algorithm& algo, const char* name, + int& value, bool readOnly=false, int (Algorithm::*getter)()=0, void (Algorithm::*setter)(int)=0, const string& help=string()); - void addParam(const Algorithm* algo, const char* name, - const bool& value, bool readOnly=false, + void addParam(Algorithm& algo, const char* name, + bool& value, bool readOnly=false, int (Algorithm::*getter)()=0, void (Algorithm::*setter)(int)=0, const string& help=string()); - void addParam(const Algorithm* algo, const char* name, - const double& value, bool readOnly=false, + void addParam(Algorithm& algo, const char* name, + double& value, bool readOnly=false, double (Algorithm::*getter)()=0, void (Algorithm::*setter)(double)=0, const string& help=string()); - void addParam(const Algorithm* algo, const char* name, - const string& value, bool readOnly=false, + void addParam(Algorithm& algo, const char* name, + string& value, bool readOnly=false, string (Algorithm::*getter)()=0, void (Algorithm::*setter)(const string&)=0, const string& help=string()); - void addParam(const Algorithm* algo, const char* name, - const Mat& value, bool readOnly=false, + void addParam(Algorithm& algo, const char* name, + Mat& value, bool readOnly=false, Mat (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Mat&)=0, const string& help=string()); - void addParam(const Algorithm* algo, const char* name, - const Ptr& value, bool readOnly=false, + void addParam(Algorithm& algo, const char* name, + Ptr& value, bool readOnly=false, Ptr (Algorithm::*getter)()=0, void (Algorithm::*setter)(const Ptr&)=0, const string& help=string()); diff --git a/modules/core/src/algorithm.cpp b/modules/core/src/algorithm.cpp index b7b084e7b..e0ab6c63c 100644 --- a/modules/core/src/algorithm.cpp +++ b/modules/core/src/algorithm.cpp @@ -541,8 +541,8 @@ void AlgorithmInfo::getParams(vector& names) const } -void AlgorithmInfo::addParam_(const Algorithm* algo, const char* name, int argType, - const void* value, bool readOnly, +void AlgorithmInfo::addParam_(Algorithm& algo, const char* name, int argType, + void* value, bool readOnly, Algorithm::Getter getter, Algorithm::Setter setter, const string& help) { @@ -550,13 +550,13 @@ void AlgorithmInfo::addParam_(const Algorithm* algo, const char* name, int argTy argType == Param::REAL || argType == Param::STRING || argType == Param::MAT || argType == Param::ALGORITHM ); data->params.add(string(name), Param(argType, readOnly, - (int)((size_t)value - (size_t)(void*)algo), + (int)((size_t)value - (size_t)(void*)&algo), getter, setter, help)); } -void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, - const int& value, bool readOnly, +void AlgorithmInfo::addParam(Algorithm& algo, const char* name, + int& value, bool readOnly, int (Algorithm::*getter)(), void (Algorithm::*setter)(int), const string& help) @@ -565,8 +565,8 @@ void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } -void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, - const bool& value, bool readOnly, +void AlgorithmInfo::addParam(Algorithm& algo, const char* name, + bool& value, bool readOnly, int (Algorithm::*getter)(), void (Algorithm::*setter)(int), const string& help) @@ -575,8 +575,8 @@ void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } -void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, - const double& value, bool readOnly, +void AlgorithmInfo::addParam(Algorithm& algo, const char* name, + double& value, bool readOnly, double (Algorithm::*getter)(), void (Algorithm::*setter)(double), const string& help) @@ -585,8 +585,8 @@ void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } -void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, - const string& value, bool readOnly, +void AlgorithmInfo::addParam(Algorithm& algo, const char* name, + string& value, bool readOnly, string (Algorithm::*getter)(), void (Algorithm::*setter)(const string&), const string& help) @@ -595,8 +595,8 @@ void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } -void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, - const Mat& value, bool readOnly, +void AlgorithmInfo::addParam(Algorithm& algo, const char* name, + Mat& value, bool readOnly, Mat (Algorithm::*getter)(), void (Algorithm::*setter)(const Mat&), const string& help) @@ -605,8 +605,8 @@ void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, (Algorithm::Getter)getter, (Algorithm::Setter)setter, help); } -void AlgorithmInfo::addParam(const Algorithm* algo, const char* name, - const Ptr& value, bool readOnly, +void AlgorithmInfo::addParam(Algorithm& algo, const char* name, + Ptr& value, bool readOnly, Ptr (Algorithm::*getter)(), void (Algorithm::*setter)(const Ptr&), const string& help) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 39bc2c85d..d14d9d504 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -481,9 +481,9 @@ public: protected: virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; - float initFeatureScale; + double initFeatureScale; int featureScaleLevels; - float featureScaleMul; + double featureScaleMul; int initXyStep; int initImgBound; diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index f68c5e58d..8fd8f402d 100644 --- a/modules/features2d/src/detectors.cpp +++ b/modules/features2d/src/detectors.cpp @@ -160,17 +160,18 @@ AlgorithmInfo* GFTTDetector::info() const static volatile bool initialized = false; if( !initialized ) { - gftt_info.addParam(this, "nfeatures", nfeatures); - gftt_info.addParam(this, "qualityLevel", qualityLevel); - gftt_info.addParam(this, "minDistance", minDistance); - gftt_info.addParam(this, "useHarrisDetector", useHarrisDetector); - gftt_info.addParam(this, "k", k); + GFTTDetector obj; + gftt_info.addParam(obj, "nfeatures", obj.nfeatures); + gftt_info.addParam(obj, "qualityLevel", obj.qualityLevel); + gftt_info.addParam(obj, "minDistance", obj.minDistance); + gftt_info.addParam(obj, "useHarrisDetector", obj.useHarrisDetector); + gftt_info.addParam(obj, "k", obj.k); - harris_info.addParam(this, "nfeatures", nfeatures); - harris_info.addParam(this, "qualityLevel", qualityLevel); - harris_info.addParam(this, "minDistance", minDistance); - harris_info.addParam(this, "useHarrisDetector", useHarrisDetector); - harris_info.addParam(this, "k", k); + harris_info.addParam(obj, "nfeatures", obj.nfeatures); + harris_info.addParam(obj, "qualityLevel", obj.qualityLevel); + harris_info.addParam(obj, "minDistance", obj.minDistance); + harris_info.addParam(obj, "useHarrisDetector", obj.useHarrisDetector); + harris_info.addParam(obj, "k", obj.k); initialized = true; } @@ -217,24 +218,25 @@ void DenseFeatureDetector::detectImpl( const Mat& image, vector& keypo static Algorithm* createDense() { return new DenseFeatureDetector; } - +static AlgorithmInfo dense_info("Feature2D.Dense", createDense); + AlgorithmInfo* DenseFeatureDetector::info() const { - static AlgorithmInfo info_("Feature2D.Dense", createDense); static volatile bool initialized = false; if( !initialized ) { - info_.addParam(this, "initFeatureScale", initFeatureScale); - info_.addParam(this, "featureScaleLevels", featureScaleLevels); - info_.addParam(this, "featureScaleMul", featureScaleMul); - info_.addParam(this, "initXyStep", initXyStep); - info_.addParam(this, "initImgBound", initImgBound); - info_.addParam(this, "varyXyStepWithScale", varyXyStepWithScale); - info_.addParam(this, "varyImgBoundWithScale", varyImgBoundWithScale); + DenseFeatureDetector obj; + dense_info.addParam(obj, "initFeatureScale", obj.initFeatureScale); + dense_info.addParam(obj, "featureScaleLevels", obj.featureScaleLevels); + dense_info.addParam(obj, "featureScaleMul", obj.featureScaleMul); + dense_info.addParam(obj, "initXyStep", obj.initXyStep); + dense_info.addParam(obj, "initImgBound", obj.initImgBound); + dense_info.addParam(obj, "varyXyStepWithScale", obj.varyXyStepWithScale); + dense_info.addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale); initialized = true; } - return &info_; + return &dense_info; } /* diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index 829a6cf99..2be9df65f 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -400,8 +400,9 @@ AlgorithmInfo* FastFeatureDetector::info() const static volatile bool initialized = false; if( !initialized ) { - fast_info.addParam(this, "threshold", threshold); - fast_info.addParam(this, "nonmaxSuppression", nonmaxSuppression); + FastFeatureDetector obj; + fast_info.addParam(obj, "threshold", obj.threshold); + fast_info.addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression); initialized = true; } diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp index a930c6006..f99bf8128 100644 --- a/modules/features2d/src/mser.cpp +++ b/modules/features2d/src/mser.cpp @@ -1307,15 +1307,16 @@ AlgorithmInfo* MSER::info() const static volatile bool initialized = false; if( !initialized ) { - mser_info.addParam(this, "delta", delta); - mser_info.addParam(this, "minArea", minArea); - mser_info.addParam(this, "maxArea", maxArea); - mser_info.addParam(this, "maxVariation", maxVariation); - mser_info.addParam(this, "minDiversity", minDiversity); - mser_info.addParam(this, "maxEvolution", maxEvolution); - mser_info.addParam(this, "areaThreshold", areaThreshold); - mser_info.addParam(this, "minMargin", minMargin); - mser_info.addParam(this, "edgeBlurSize", edgeBlurSize); + 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; } diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 2219f9c10..4255cced1 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -556,14 +556,15 @@ AlgorithmInfo* ORB::info() const static volatile bool initialized = false; if( !initialized ) { - orb_info.addParam(this, "nFeatures", nfeatures); - orb_info.addParam(this, "scaleFactor", scaleFactor); - orb_info.addParam(this, "nLevels", nlevels); - orb_info.addParam(this, "firstLevel", firstLevel); - orb_info.addParam(this, "edgeThreshold", edgeThreshold); - orb_info.addParam(this, "patchSize", patchSize); - orb_info.addParam(this, "WTA_K", WTA_K); - orb_info.addParam(this, "scoreType", scoreType); + 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; } diff --git a/modules/features2d/src/stardetector.cpp b/modules/features2d/src/stardetector.cpp index 3f758995d..60c332e88 100644 --- a/modules/features2d/src/stardetector.cpp +++ b/modules/features2d/src/stardetector.cpp @@ -456,11 +456,12 @@ AlgorithmInfo* StarDetector::info() const static volatile bool initialized = false; if( !initialized ) { - star_info.addParam(this, "maxSize", maxSize); - star_info.addParam(this, "responseThreshold", responseThreshold); - star_info.addParam(this, "lineThresholdProjected", lineThresholdProjected); - star_info.addParam(this, "lineThresholdBinarized", lineThresholdBinarized); - star_info.addParam(this, "suppressNonmaxSize", suppressNonmaxSize); + 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; } diff --git a/modules/nonfree/src/sift.cpp b/modules/nonfree/src/sift.cpp index bb5e1ef21..cca832214 100644 --- a/modules/nonfree/src/sift.cpp +++ b/modules/nonfree/src/sift.cpp @@ -683,11 +683,12 @@ AlgorithmInfo* SIFT::info() const static volatile bool initialized = false; if( !initialized ) { - sift_info.addParam(this, "nFeatures", nfeatures); - sift_info.addParam(this, "nOctaveLayers", nOctaveLayers); - sift_info.addParam(this, "contrastThreshold", contrastThreshold); - sift_info.addParam(this, "edgeThreshold", edgeThreshold); - sift_info.addParam(this, "sigma", sigma); + 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; } diff --git a/modules/nonfree/src/surf.cpp b/modules/nonfree/src/surf.cpp index 8e2c1a8ba..617018cc6 100644 --- a/modules/nonfree/src/surf.cpp +++ b/modules/nonfree/src/surf.cpp @@ -930,11 +930,12 @@ AlgorithmInfo* SURF::info() const static volatile bool initialized = false; if( !initialized ) { - surf_info.addParam(this, "hessianThreshold", hessianThreshold); - surf_info.addParam(this, "nOctaves", nOctaves); - surf_info.addParam(this, "nOctaveLayers", nOctaveLayers); - surf_info.addParam(this, "extended", extended); - surf_info.addParam(this, "upright", upright); + SURF obj; + surf_info.addParam(obj, "hessianThreshold", obj.hessianThreshold); + surf_info.addParam(obj, "nOctaves", obj.nOctaves); + surf_info.addParam(obj, "nOctaveLayers", obj.nOctaveLayers); + surf_info.addParam(obj, "extended", obj.extended); + surf_info.addParam(obj, "upright", obj.upright); initialized = true; } diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index 39b808c4b..7ea03c6ee 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -1814,7 +1814,7 @@ void VocData::getSortOrder(const vector& values, vector& order, b void VocData::readFileToString(const string filename, string& file_contents) { std::ifstream ifs(filename.c_str()); - if (ifs == false) CV_Error(CV_StsError,"could not open text file"); + if (!ifs.is_open()) CV_Error(CV_StsError,"could not open text file"); stringstream oss; oss << ifs.rdbuf();