1
0
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:
Alexander Alekhin
2018-03-15 16:16:58 +03:00
parent 3314966acb
commit 4d0dd3e509
13 changed files with 370 additions and 301 deletions
+35 -35
View File
@@ -119,7 +119,7 @@ Mat TrainData::getSubVector(const Mat& vec, const Mat& idx)
return subvec;
}
class TrainDataImpl : public TrainData
class TrainDataImpl CV_FINAL : public TrainData
{
public:
typedef std::map<String, int> MapType;
@@ -132,75 +132,75 @@ public:
virtual ~TrainDataImpl() { closeFile(); }
int getLayout() const { return layout; }
int getNSamples() const
int getLayout() const CV_OVERRIDE { return layout; }
int getNSamples() const CV_OVERRIDE
{
return !sampleIdx.empty() ? (int)sampleIdx.total() :
layout == ROW_SAMPLE ? samples.rows : samples.cols;
}
int getNTrainSamples() const
int getNTrainSamples() const CV_OVERRIDE
{
return !trainSampleIdx.empty() ? (int)trainSampleIdx.total() : getNSamples();
}
int getNTestSamples() const
int getNTestSamples() const CV_OVERRIDE
{
return !testSampleIdx.empty() ? (int)testSampleIdx.total() : 0;
}
int getNVars() const
int getNVars() const CV_OVERRIDE
{
return !varIdx.empty() ? (int)varIdx.total() : getNAllVars();
}
int getNAllVars() const
int getNAllVars() const CV_OVERRIDE
{
return layout == ROW_SAMPLE ? samples.cols : samples.rows;
}
Mat getSamples() const { return samples; }
Mat getResponses() const { return responses; }
Mat getMissing() const { return missing; }
Mat getVarIdx() const { return varIdx; }
Mat getVarType() const { return varType; }
int getResponseType() const
Mat getSamples() const CV_OVERRIDE { return samples; }
Mat getResponses() const CV_OVERRIDE { return responses; }
Mat getMissing() const CV_OVERRIDE { return missing; }
Mat getVarIdx() const CV_OVERRIDE { return varIdx; }
Mat getVarType() const CV_OVERRIDE { return varType; }
int getResponseType() const CV_OVERRIDE
{
return classLabels.empty() ? VAR_ORDERED : VAR_CATEGORICAL;
}
Mat getTrainSampleIdx() const { return !trainSampleIdx.empty() ? trainSampleIdx : sampleIdx; }
Mat getTestSampleIdx() const { return testSampleIdx; }
Mat getSampleWeights() const
Mat getTrainSampleIdx() const CV_OVERRIDE { return !trainSampleIdx.empty() ? trainSampleIdx : sampleIdx; }
Mat getTestSampleIdx() const CV_OVERRIDE { return testSampleIdx; }
Mat getSampleWeights() const CV_OVERRIDE
{
return sampleWeights;
}
Mat getTrainSampleWeights() const
Mat getTrainSampleWeights() const CV_OVERRIDE
{
return getSubVector(sampleWeights, getTrainSampleIdx());
}
Mat getTestSampleWeights() const
Mat getTestSampleWeights() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(sampleWeights, idx);
}
Mat getTrainResponses() const
Mat getTrainResponses() const CV_OVERRIDE
{
return getSubVector(responses, getTrainSampleIdx());
}
Mat getTrainNormCatResponses() const
Mat getTrainNormCatResponses() const CV_OVERRIDE
{
return getSubVector(normCatResponses, getTrainSampleIdx());
}
Mat getTestResponses() const
Mat getTestResponses() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(responses, idx);
}
Mat getTestNormCatResponses() const
Mat getTestNormCatResponses() const CV_OVERRIDE
{
Mat idx = getTestSampleIdx();
return idx.empty() ? Mat() : getSubVector(normCatResponses, idx);
}
Mat getNormCatResponses() const { return normCatResponses; }
Mat getClassLabels() const { return classLabels; }
Mat getNormCatResponses() const CV_OVERRIDE { return normCatResponses; }
Mat getClassLabels() const CV_OVERRIDE { return classLabels; }
Mat getClassCounters() const { return classCounters; }
int getCatCount(int vi) const
int getCatCount(int vi) const CV_OVERRIDE
{
int n = (int)catOfs.total();
CV_Assert( 0 <= vi && vi < n );
@@ -208,10 +208,10 @@ public:
return ofs[1] - ofs[0];
}
Mat getCatOfs() const { return catOfs; }
Mat getCatMap() const { return catMap; }
Mat getCatOfs() const CV_OVERRIDE { return catOfs; }
Mat getCatMap() const CV_OVERRIDE { return catMap; }
Mat getDefaultSubstValues() const { return missingSubst; }
Mat getDefaultSubstValues() const CV_OVERRIDE { return missingSubst; }
void closeFile() { if(file) fclose(file); file=0; }
void clear()
@@ -767,13 +767,13 @@ public:
CV_Error( CV_StsBadArg, "type of some variables is not specified" );
}
void setTrainTestSplitRatio(double ratio, bool shuffle)
void setTrainTestSplitRatio(double ratio, bool shuffle) CV_OVERRIDE
{
CV_Assert( 0. <= ratio && ratio <= 1. );
setTrainTestSplit(cvRound(getNSamples()*ratio), shuffle);
}
void setTrainTestSplit(int count, bool shuffle)
void setTrainTestSplit(int count, bool shuffle) CV_OVERRIDE
{
int i, nsamples = getNSamples();
CV_Assert( 0 <= count && count < nsamples );
@@ -810,7 +810,7 @@ public:
}
}
void shuffleTrainTest()
void shuffleTrainTest() CV_OVERRIDE
{
if( !trainSampleIdx.empty() && !testSampleIdx.empty() )
{
@@ -844,7 +844,7 @@ public:
Mat getTrainSamples(int _layout,
bool compressSamples,
bool compressVars) const
bool compressVars) const CV_OVERRIDE
{
if( samples.empty() )
return samples;
@@ -884,7 +884,7 @@ public:
return dsamples;
}
void getValues( int vi, InputArray _sidx, float* values ) const
void getValues( int vi, InputArray _sidx, float* values ) const CV_OVERRIDE
{
Mat sidx = _sidx.getMat();
int i, n = sidx.checkVector(1, CV_32S), nsamples = getNSamples();
@@ -914,7 +914,7 @@ public:
}
}
void getNormCatValues( int vi, InputArray _sidx, int* values ) const
void getNormCatValues( int vi, InputArray _sidx, int* values ) const CV_OVERRIDE
{
float* fvalues = (float*)values;
getValues(vi, _sidx, fvalues);
@@ -960,7 +960,7 @@ public:
}
}
void getSample(InputArray _vidx, int sidx, float* buf) const
void getSample(InputArray _vidx, int sidx, float* buf) const CV_OVERRIDE
{
CV_Assert(buf != 0 && 0 <= sidx && sidx < getNSamples());
Mat vidx = _vidx.getMat();