mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
ml: apply CV_OVERRIDE/CV_FINAL
This commit is contained in:
+23
-22
@@ -48,7 +48,7 @@ namespace ml
|
||||
|
||||
const double minEigenValue = DBL_EPSILON;
|
||||
|
||||
class CV_EXPORTS EMImpl : public EM
|
||||
class CV_EXPORTS EMImpl CV_FINAL : public EM
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -56,20 +56,21 @@ public:
|
||||
int covMatType;
|
||||
TermCriteria termCrit;
|
||||
|
||||
CV_IMPL_PROPERTY_S(TermCriteria, TermCriteria, termCrit)
|
||||
inline TermCriteria getTermCriteria() const CV_OVERRIDE { return termCrit; }
|
||||
inline void setTermCriteria(const TermCriteria& val) CV_OVERRIDE { termCrit = val; }
|
||||
|
||||
void setClustersNumber(int val)
|
||||
void setClustersNumber(int val) CV_OVERRIDE
|
||||
{
|
||||
nclusters = val;
|
||||
CV_Assert(nclusters >= 1);
|
||||
}
|
||||
|
||||
int getClustersNumber() const
|
||||
int getClustersNumber() const CV_OVERRIDE
|
||||
{
|
||||
return nclusters;
|
||||
}
|
||||
|
||||
void setCovarianceMatrixType(int val)
|
||||
void setCovarianceMatrixType(int val) CV_OVERRIDE
|
||||
{
|
||||
covMatType = val;
|
||||
CV_Assert(covMatType == COV_MAT_SPHERICAL ||
|
||||
@@ -77,7 +78,7 @@ public:
|
||||
covMatType == COV_MAT_GENERIC);
|
||||
}
|
||||
|
||||
int getCovarianceMatrixType() const
|
||||
int getCovarianceMatrixType() const CV_OVERRIDE
|
||||
{
|
||||
return covMatType;
|
||||
}
|
||||
@@ -91,7 +92,7 @@ public:
|
||||
|
||||
virtual ~EMImpl() {}
|
||||
|
||||
void clear()
|
||||
void clear() CV_OVERRIDE
|
||||
{
|
||||
trainSamples.release();
|
||||
trainProbs.release();
|
||||
@@ -109,7 +110,7 @@ public:
|
||||
logWeightDivDet.release();
|
||||
}
|
||||
|
||||
bool train(const Ptr<TrainData>& data, int)
|
||||
bool train(const Ptr<TrainData>& data, int) CV_OVERRIDE
|
||||
{
|
||||
Mat samples = data->getTrainSamples(), labels;
|
||||
return trainEM(samples, labels, noArray(), noArray());
|
||||
@@ -118,7 +119,7 @@ public:
|
||||
bool trainEM(InputArray samples,
|
||||
OutputArray logLikelihoods,
|
||||
OutputArray labels,
|
||||
OutputArray probs)
|
||||
OutputArray probs) CV_OVERRIDE
|
||||
{
|
||||
Mat samplesMat = samples.getMat();
|
||||
setTrainData(START_AUTO_STEP, samplesMat, 0, 0, 0, 0);
|
||||
@@ -131,7 +132,7 @@ public:
|
||||
InputArray _weights0,
|
||||
OutputArray logLikelihoods,
|
||||
OutputArray labels,
|
||||
OutputArray probs)
|
||||
OutputArray probs) CV_OVERRIDE
|
||||
{
|
||||
Mat samplesMat = samples.getMat();
|
||||
std::vector<Mat> covs0;
|
||||
@@ -148,7 +149,7 @@ public:
|
||||
InputArray _probs0,
|
||||
OutputArray logLikelihoods,
|
||||
OutputArray labels,
|
||||
OutputArray probs)
|
||||
OutputArray probs) CV_OVERRIDE
|
||||
{
|
||||
Mat samplesMat = samples.getMat();
|
||||
Mat probs0 = _probs0.getMat();
|
||||
@@ -157,7 +158,7 @@ public:
|
||||
return doTrain(START_M_STEP, logLikelihoods, labels, probs);
|
||||
}
|
||||
|
||||
float predict(InputArray _inputs, OutputArray _outputs, int) const
|
||||
float predict(InputArray _inputs, OutputArray _outputs, int) const CV_OVERRIDE
|
||||
{
|
||||
bool needprobs = _outputs.needed();
|
||||
Mat samples = _inputs.getMat(), probs, probsrow;
|
||||
@@ -186,7 +187,7 @@ public:
|
||||
return firstres;
|
||||
}
|
||||
|
||||
Vec2d predict2(InputArray _sample, OutputArray _probs) const
|
||||
Vec2d predict2(InputArray _sample, OutputArray _probs) const CV_OVERRIDE
|
||||
{
|
||||
int ptype = CV_64F;
|
||||
Mat sample = _sample.getMat();
|
||||
@@ -213,22 +214,22 @@ public:
|
||||
return computeProbabilities(sample, !probs.empty() ? &probs : 0, ptype);
|
||||
}
|
||||
|
||||
bool isTrained() const
|
||||
bool isTrained() const CV_OVERRIDE
|
||||
{
|
||||
return !means.empty();
|
||||
}
|
||||
|
||||
bool isClassifier() const
|
||||
bool isClassifier() const CV_OVERRIDE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int getVarCount() const
|
||||
int getVarCount() const CV_OVERRIDE
|
||||
{
|
||||
return means.cols;
|
||||
}
|
||||
|
||||
String getDefaultName() const
|
||||
String getDefaultName() const CV_OVERRIDE
|
||||
{
|
||||
return "opencv_ml_em";
|
||||
}
|
||||
@@ -768,7 +769,7 @@ public:
|
||||
writeTermCrit(fs, termCrit);
|
||||
}
|
||||
|
||||
void write(FileStorage& fs) const
|
||||
void write(FileStorage& fs) const CV_OVERRIDE
|
||||
{
|
||||
writeFormat(fs);
|
||||
fs << "training_params" << "{";
|
||||
@@ -796,7 +797,7 @@ public:
|
||||
termCrit = readTermCrit(fn);
|
||||
}
|
||||
|
||||
void read(const FileNode& fn)
|
||||
void read(const FileNode& fn) CV_OVERRIDE
|
||||
{
|
||||
clear();
|
||||
read_params(fn["training_params"]);
|
||||
@@ -816,9 +817,9 @@ public:
|
||||
computeLogWeightDivDet();
|
||||
}
|
||||
|
||||
Mat getWeights() const { return weights; }
|
||||
Mat getMeans() const { return means; }
|
||||
void getCovs(std::vector<Mat>& _covs) const
|
||||
Mat getWeights() const CV_OVERRIDE { return weights; }
|
||||
Mat getMeans() const CV_OVERRIDE { return means; }
|
||||
void getCovs(std::vector<Mat>& _covs) const CV_OVERRIDE
|
||||
{
|
||||
_covs.resize(covs.size());
|
||||
std::copy(covs.begin(), covs.end(), _covs.begin());
|
||||
|
||||
Reference in New Issue
Block a user