minor change: moved algorithm type to the end of params

pull/3126/head
Dmitriy Anisimov 11 years ago
parent dfaf75f502
commit a6b29be55b
  1. 4
      modules/ml/include/opencv2/ml.hpp
  2. 6
      modules/ml/src/knearest.cpp
  3. 2
      modules/ml/test/test_emknearestkmeans.cpp

@ -230,12 +230,12 @@ public:
class CV_EXPORTS_W_MAP Params class CV_EXPORTS_W_MAP Params
{ {
public: public:
Params(int algorithmType_=BRUTE_FORCE, int defaultK=10, bool isclassifier_=true, int Emax_=INT_MAX); Params(int defaultK=10, bool isclassifier_=true, int Emax_=INT_MAX, int algorithmType_=BRUTE_FORCE);
CV_PROP_RW int algorithmType;
CV_PROP_RW int defaultK; CV_PROP_RW int defaultK;
CV_PROP_RW bool isclassifier; CV_PROP_RW bool isclassifier;
CV_PROP_RW int Emax; // for implementation with KDTree CV_PROP_RW int Emax; // for implementation with KDTree
CV_PROP_RW int algorithmType;
}; };
virtual void setParams(const Params& p) = 0; virtual void setParams(const Params& p) = 0;
virtual Params getParams() const = 0; virtual Params getParams() const = 0;

@ -50,11 +50,11 @@
namespace cv { namespace cv {
namespace ml { namespace ml {
KNearest::Params::Params(int algorithmType_, int k, bool isclassifier_, int Emax_) : KNearest::Params::Params(int k, bool isclassifier_, int Emax_, int algorithmType_) :
algorithmType(algorithmType_),
defaultK(k), defaultK(k),
isclassifier(isclassifier_), isclassifier(isclassifier_),
Emax(Emax_) Emax(Emax_),
algorithmType(algorithmType_)
{ {
} }

@ -330,7 +330,7 @@ void CV_KNearestTest::run( int /*start_from*/ )
} }
// KNearest KDTree implementation // KNearest KDTree implementation
Ptr<KNearest> knearestKdt = KNearest::create(ml::KNearest::Params(ml::KNearest::KDTREE)); Ptr<KNearest> knearestKdt = KNearest::create(ml::KNearest::Params(10, true, INT_MAX, ml::KNearest::KDTREE));
knearestKdt->train(trainData, ml::ROW_SAMPLE, trainLabels); knearestKdt->train(trainData, ml::ROW_SAMPLE, trainLabels);
knearestKdt->findNearest(testData, 4, bestLabels); knearestKdt->findNearest(testData, 4, bestLabels);
if( !calcErr( bestLabels, testLabels, sizes, err, true ) ) if( !calcErr( bestLabels, testLabels, sizes, err, true ) )

Loading…
Cancel
Save