mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
ml: apply CV_OVERRIDE/CV_FINAL
This commit is contained in:
+28
-25
@@ -134,11 +134,11 @@ public:
|
||||
Mat responses;
|
||||
};
|
||||
|
||||
class BruteForceImpl : public Impl
|
||||
class BruteForceImpl CV_FINAL : public Impl
|
||||
{
|
||||
public:
|
||||
String getModelName() const { return NAME_BRUTE_FORCE; }
|
||||
int getType() const { return ml::KNearest::BRUTE_FORCE; }
|
||||
String getModelName() const CV_OVERRIDE { return NAME_BRUTE_FORCE; }
|
||||
int getType() const CV_OVERRIDE { return ml::KNearest::BRUTE_FORCE; }
|
||||
|
||||
void findNearestCore( const Mat& _samples, int k0, const Range& range,
|
||||
Mat* results, Mat* neighbor_responses,
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
presult = _presult;
|
||||
}
|
||||
|
||||
void operator()( const Range& range ) const
|
||||
void operator()(const Range& range) const CV_OVERRIDE
|
||||
{
|
||||
int delta = std::min(range.end - range.start, 256);
|
||||
for( int start = range.start; start < range.end; start += delta )
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
float findNearest( InputArray _samples, int k,
|
||||
OutputArray _results,
|
||||
OutputArray _neighborResponses,
|
||||
OutputArray _dists ) const
|
||||
OutputArray _dists ) const CV_OVERRIDE
|
||||
{
|
||||
float result = 0.f;
|
||||
CV_Assert( 0 < k );
|
||||
@@ -358,13 +358,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class KDTreeImpl : public Impl
|
||||
class KDTreeImpl CV_FINAL : public Impl
|
||||
{
|
||||
public:
|
||||
String getModelName() const { return NAME_KDTREE; }
|
||||
int getType() const { return ml::KNearest::KDTREE; }
|
||||
String getModelName() const CV_OVERRIDE { return NAME_KDTREE; }
|
||||
int getType() const CV_OVERRIDE { return ml::KNearest::KDTREE; }
|
||||
|
||||
void doTrain(InputArray points)
|
||||
void doTrain(InputArray points) CV_OVERRIDE
|
||||
{
|
||||
tr.build(points);
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public:
|
||||
float findNearest( InputArray _samples, int k,
|
||||
OutputArray _results,
|
||||
OutputArray _neighborResponses,
|
||||
OutputArray _dists ) const
|
||||
OutputArray _dists ) const CV_OVERRIDE
|
||||
{
|
||||
float result = 0.f;
|
||||
CV_Assert( 0 < k );
|
||||
@@ -432,18 +432,21 @@ public:
|
||||
|
||||
//================================================================
|
||||
|
||||
class KNearestImpl : public KNearest
|
||||
class KNearestImpl CV_FINAL : public KNearest
|
||||
{
|
||||
CV_IMPL_PROPERTY(int, DefaultK, impl->defaultK)
|
||||
CV_IMPL_PROPERTY(bool, IsClassifier, impl->isclassifier)
|
||||
CV_IMPL_PROPERTY(int, Emax, impl->Emax)
|
||||
inline int getDefaultK() const CV_OVERRIDE { return impl->defaultK; }
|
||||
inline void setDefaultK(int val) CV_OVERRIDE { impl->defaultK = val; }
|
||||
inline bool getIsClassifier() const CV_OVERRIDE { return impl->isclassifier; }
|
||||
inline void setIsClassifier(bool val) CV_OVERRIDE { impl->isclassifier = val; }
|
||||
inline int getEmax() const CV_OVERRIDE { return impl->Emax; }
|
||||
inline void setEmax(int val) CV_OVERRIDE { impl->Emax = val; }
|
||||
|
||||
public:
|
||||
int getAlgorithmType() const
|
||||
int getAlgorithmType() const CV_OVERRIDE
|
||||
{
|
||||
return impl->getType();
|
||||
}
|
||||
void setAlgorithmType(int val)
|
||||
void setAlgorithmType(int val) CV_OVERRIDE
|
||||
{
|
||||
if (val != BRUTE_FORCE && val != KDTREE)
|
||||
val = BRUTE_FORCE;
|
||||
@@ -459,18 +462,18 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool isClassifier() const { return impl->isclassifier; }
|
||||
bool isTrained() const { return !impl->samples.empty(); }
|
||||
bool isClassifier() const CV_OVERRIDE { return impl->isclassifier; }
|
||||
bool isTrained() const CV_OVERRIDE { return !impl->samples.empty(); }
|
||||
|
||||
int getVarCount() const { return impl->samples.cols; }
|
||||
int getVarCount() const CV_OVERRIDE { return impl->samples.cols; }
|
||||
|
||||
void write( FileStorage& fs ) const
|
||||
void write( FileStorage& fs ) const CV_OVERRIDE
|
||||
{
|
||||
writeFormat(fs);
|
||||
impl->write(fs);
|
||||
}
|
||||
|
||||
void read( const FileNode& fn )
|
||||
void read( const FileNode& fn ) CV_OVERRIDE
|
||||
{
|
||||
int algorithmType = BRUTE_FORCE;
|
||||
if (fn.name() == NAME_KDTREE)
|
||||
@@ -482,22 +485,22 @@ public:
|
||||
float findNearest( InputArray samples, int k,
|
||||
OutputArray results,
|
||||
OutputArray neighborResponses=noArray(),
|
||||
OutputArray dist=noArray() ) const
|
||||
OutputArray dist=noArray() ) const CV_OVERRIDE
|
||||
{
|
||||
return impl->findNearest(samples, k, results, neighborResponses, dist);
|
||||
}
|
||||
|
||||
float predict(InputArray inputs, OutputArray outputs, int) const
|
||||
float predict(InputArray inputs, OutputArray outputs, int) const CV_OVERRIDE
|
||||
{
|
||||
return impl->findNearest( inputs, impl->defaultK, outputs, noArray(), noArray() );
|
||||
}
|
||||
|
||||
bool train( const Ptr<TrainData>& data, int flags )
|
||||
bool train( const Ptr<TrainData>& data, int flags ) CV_OVERRIDE
|
||||
{
|
||||
return impl->train(data, flags);
|
||||
}
|
||||
|
||||
String getDefaultName() const { return impl->getModelName(); }
|
||||
String getDefaultName() const CV_OVERRIDE { return impl->getModelName(); }
|
||||
|
||||
protected:
|
||||
void initImpl(int algorithmType)
|
||||
|
||||
Reference in New Issue
Block a user