mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Partially back-port #25075 to 4.x
This commit is contained in:
+10
-10
@@ -223,7 +223,7 @@ public:
|
||||
void setActivationFunction(int _activ_func, double _f_param1, double _f_param2) CV_OVERRIDE
|
||||
{
|
||||
if( _activ_func < 0 || _activ_func > LEAKYRELU)
|
||||
CV_Error( CV_StsOutOfRange, "Unknown activation function" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "Unknown activation function" );
|
||||
|
||||
activ_func = _activ_func;
|
||||
|
||||
@@ -322,7 +322,7 @@ public:
|
||||
{
|
||||
int n = layer_sizes[i];
|
||||
if( n < 1 + (0 < i && i < l_count-1))
|
||||
CV_Error( CV_StsOutOfRange,
|
||||
CV_Error( cv::Error::StsOutOfRange,
|
||||
"there should be at least one input and one output "
|
||||
"and every hidden layer must have more than 1 neuron" );
|
||||
max_lsize = std::max( max_lsize, n );
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
float predict( InputArray _inputs, OutputArray _outputs, int ) const CV_OVERRIDE
|
||||
{
|
||||
if( !trained )
|
||||
CV_Error( CV_StsError, "The network has not been trained or loaded" );
|
||||
CV_Error( cv::Error::StsError, "The network has not been trained or loaded" );
|
||||
|
||||
Mat inputs = _inputs.getMat();
|
||||
int type = inputs.type(), l_count = layer_count();
|
||||
@@ -790,7 +790,7 @@ public:
|
||||
{
|
||||
t = t*inv_scale[j*2] + inv_scale[2*j+1];
|
||||
if( t < m1 || t > M1 )
|
||||
CV_Error( CV_StsOutOfRange,
|
||||
CV_Error( cv::Error::StsOutOfRange,
|
||||
"Some of new output training vector components run exceed the original range too much" );
|
||||
}
|
||||
}
|
||||
@@ -817,25 +817,25 @@ public:
|
||||
Mat& sample_weights, int flags )
|
||||
{
|
||||
if( layer_sizes.empty() )
|
||||
CV_Error( CV_StsError,
|
||||
CV_Error( cv::Error::StsError,
|
||||
"The network has not been created. Use method create or the appropriate constructor" );
|
||||
|
||||
if( (inputs.type() != CV_32F && inputs.type() != CV_64F) ||
|
||||
inputs.cols != layer_sizes[0] )
|
||||
CV_Error( CV_StsBadArg,
|
||||
CV_Error( cv::Error::StsBadArg,
|
||||
"input training data should be a floating-point matrix with "
|
||||
"the number of rows equal to the number of training samples and "
|
||||
"the number of columns equal to the size of 0-th (input) layer" );
|
||||
|
||||
if( (outputs.type() != CV_32F && outputs.type() != CV_64F) ||
|
||||
outputs.cols != layer_sizes.back() )
|
||||
CV_Error( CV_StsBadArg,
|
||||
CV_Error( cv::Error::StsBadArg,
|
||||
"output training data should be a floating-point matrix with "
|
||||
"the number of rows equal to the number of training samples and "
|
||||
"the number of columns equal to the size of last (output) layer" );
|
||||
|
||||
if( inputs.rows != outputs.rows )
|
||||
CV_Error( CV_StsUnmatchedSizes, "The numbers of input and output samples do not match" );
|
||||
CV_Error( cv::Error::StsUnmatchedSizes, "The numbers of input and output samples do not match" );
|
||||
|
||||
Mat temp;
|
||||
double s = sum(sample_weights)[0];
|
||||
@@ -1323,7 +1323,7 @@ public:
|
||||
fs << "itePerStep" << params.itePerStep;
|
||||
}
|
||||
else
|
||||
CV_Error(CV_StsError, "Unknown training method");
|
||||
CV_Error(cv::Error::StsError, "Unknown training method");
|
||||
|
||||
fs << "term_criteria" << "{";
|
||||
if( params.termCrit.type & TermCriteria::EPS )
|
||||
@@ -1421,7 +1421,7 @@ public:
|
||||
params.itePerStep = tpn["itePerStep"];
|
||||
}
|
||||
else
|
||||
CV_Error(CV_StsParseError, "Unknown training method (should be BACKPROP or RPROP)");
|
||||
CV_Error(cv::Error::StsParseError, "Unknown training method (should be BACKPROP or RPROP)");
|
||||
|
||||
FileNode tcn = tpn["term_criteria"];
|
||||
if( !tcn.empty() )
|
||||
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
}
|
||||
}
|
||||
else
|
||||
CV_Error(CV_StsNotImplemented, "Unknown boosting type");
|
||||
CV_Error(cv::Error::StsNotImplemented, "Unknown boosting type");
|
||||
|
||||
/*if( bparams.boostType != Boost::LOGIT )
|
||||
{
|
||||
@@ -387,7 +387,7 @@ public:
|
||||
void write( FileStorage& fs ) const CV_OVERRIDE
|
||||
{
|
||||
if( roots.empty() )
|
||||
CV_Error( CV_StsBadArg, "RTrees have not been trained" );
|
||||
CV_Error( cv::Error::StsBadArg, "RTrees have not been trained" );
|
||||
|
||||
writeFormat(fs);
|
||||
writeParams(fs);
|
||||
|
||||
@@ -574,7 +574,7 @@ public:
|
||||
if( nvars == 0 )
|
||||
{
|
||||
if( rowvals.empty() )
|
||||
CV_Error(CV_StsBadArg, "invalid CSV format; no data found");
|
||||
CV_Error(cv::Error::StsBadArg, "invalid CSV format; no data found");
|
||||
nvars = (int)rowvals.size();
|
||||
if( !varTypeSpec.empty() && varTypeSpec.size() > 0 )
|
||||
{
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
{
|
||||
for( i = ninputvars; i < nvars; i++ )
|
||||
if( vtypes[i] == VAR_CATEGORICAL )
|
||||
CV_Error(CV_StsBadArg,
|
||||
CV_Error(cv::Error::StsBadArg,
|
||||
"If responses are vector values, not scalars, they must be marked as ordered responses");
|
||||
}
|
||||
}
|
||||
@@ -724,14 +724,14 @@ public:
|
||||
}
|
||||
|
||||
if ( ptr[3] != '[')
|
||||
CV_Error( CV_StsBadArg, errmsg );
|
||||
CV_Error( cv::Error::StsBadArg, errmsg );
|
||||
|
||||
ptr += 4; // pass "ord["
|
||||
do
|
||||
{
|
||||
int b1 = (int)strtod( ptr, &stopstring );
|
||||
if( *stopstring == 0 || (*stopstring != ',' && *stopstring != ']' && *stopstring != '-') )
|
||||
CV_Error( CV_StsBadArg, errmsg );
|
||||
CV_Error( cv::Error::StsBadArg, errmsg );
|
||||
ptr = stopstring + 1;
|
||||
if( (stopstring[0] == ',') || (stopstring[0] == ']'))
|
||||
{
|
||||
@@ -745,7 +745,7 @@ public:
|
||||
{
|
||||
int b2 = (int)strtod( ptr, &stopstring);
|
||||
if ( (*stopstring == 0) || (*stopstring != ',' && *stopstring != ']') )
|
||||
CV_Error( CV_StsBadArg, errmsg );
|
||||
CV_Error( cv::Error::StsBadArg, errmsg );
|
||||
ptr = stopstring + 1;
|
||||
CV_Assert( 0 <= b1 && b1 <= b2 && b2 < nvars );
|
||||
for (int i = b1; i <= b2; i++)
|
||||
@@ -753,7 +753,7 @@ public:
|
||||
specCounter += b2 - b1 + 1;
|
||||
}
|
||||
else
|
||||
CV_Error( CV_StsBadArg, errmsg );
|
||||
CV_Error( cv::Error::StsBadArg, errmsg );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -762,7 +762,7 @@ public:
|
||||
}
|
||||
|
||||
if( specCounter != nvars )
|
||||
CV_Error( CV_StsBadArg, "type of some variables is not specified" );
|
||||
CV_Error( cv::Error::StsBadArg, "type of some variables is not specified" );
|
||||
}
|
||||
|
||||
void setTrainTestSplitRatio(double ratio, bool shuffle) CV_OVERRIDE
|
||||
|
||||
@@ -218,7 +218,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag,
|
||||
orig_response->data.fl[i] = (float) _responses->data.i[i*step];
|
||||
}; break;
|
||||
default:
|
||||
CV_Error(CV_StsUnmatchedFormats, "Response should be a 32fC1 or 32sC1 vector.");
|
||||
CV_Error(cv::Error::StsUnmatchedFormats, "Response should be a 32fC1 or 32sC1 vector.");
|
||||
}
|
||||
|
||||
if (!is_regression)
|
||||
@@ -283,7 +283,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag,
|
||||
sample_idx->data.i[active_samples_count++] = i;
|
||||
|
||||
} break;
|
||||
default: CV_Error(CV_StsUnmatchedFormats, "_sample_idx should be a 32sC1, 8sC1 or 8uC1 vector.");
|
||||
default: CV_Error(cv::Error::StsUnmatchedFormats, "_sample_idx should be a 32sC1, 8sC1 or 8uC1 vector.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1072,7 +1072,7 @@ void CvGBTrees::read_params( CvFileStorage* fs, CvFileNode* fnode )
|
||||
|
||||
|
||||
if( params.loss_function_type < SQUARED_LOSS || params.loss_function_type > DEVIANCE_LOSS || params.loss_function_type == 2)
|
||||
CV_ERROR( CV_StsBadArg, "Unknown loss function" );
|
||||
CV_ERROR( cv::Error::StsBadArg, "Unknown loss function" );
|
||||
|
||||
params.weak_count = cvReadIntByName( fs, fnode, "ensemble_length" );
|
||||
params.shrinkage = (float)cvReadRealByName( fs, fnode, "shrinkage", 0.1 );
|
||||
@@ -1082,7 +1082,7 @@ void CvGBTrees::read_params( CvFileStorage* fs, CvFileNode* fnode )
|
||||
{
|
||||
class_labels = (CvMat*)cvReadByName( fs, fnode, "class_labels" );
|
||||
if( class_labels && !CV_IS_MAT(class_labels))
|
||||
CV_ERROR( CV_StsParseError, "class_labels must stored as a matrix");
|
||||
CV_ERROR( cv::Error::StsParseError, "class_labels must stored as a matrix");
|
||||
}
|
||||
data->is_classifier = 0;
|
||||
|
||||
@@ -1105,7 +1105,7 @@ void CvGBTrees::write( CvFileStorage* fs, const char* name ) const
|
||||
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_GBT );
|
||||
|
||||
if( !weak )
|
||||
CV_ERROR( CV_StsBadArg, "The model has not been trained yet" );
|
||||
CV_ERROR( cv::Error::StsBadArg, "The model has not been trained yet" );
|
||||
|
||||
write_params( fs );
|
||||
cvWriteReal( fs, "base_value", base_value);
|
||||
@@ -1170,13 +1170,13 @@ void CvGBTrees::read( CvFileStorage* fs, CvFileNode* node )
|
||||
|
||||
trees_fnode = cvGetFileNodeByName( fs, node, s.c_str() );
|
||||
if( !trees_fnode || !CV_NODE_IS_SEQ(trees_fnode->tag) )
|
||||
CV_ERROR( CV_StsParseError, "<trees_x> tag is missing" );
|
||||
CV_ERROR( cv::Error::StsParseError, "<trees_x> tag is missing" );
|
||||
|
||||
cvStartReadSeq( trees_fnode->data.seq, &reader );
|
||||
ntrees = trees_fnode->data.seq->total;
|
||||
|
||||
if( ntrees != params.weak_count )
|
||||
CV_ERROR( CV_StsUnmatchedSizes,
|
||||
CV_ERROR( cv::Error::StsUnmatchedSizes,
|
||||
"The number of trees stored does not match <ntrees> tag value" );
|
||||
|
||||
CV_CALL( storage = cvCreateMemStorage() );
|
||||
|
||||
@@ -63,7 +63,7 @@ bool StatModel::train(const Ptr<TrainData>& trainData, int )
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_Assert(!trainData.empty());
|
||||
CV_Error(CV_StsNotImplemented, "");
|
||||
CV_Error(cv::Error::StsNotImplemented, "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -109,15 +109,15 @@ bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int)
|
||||
CV_Assert( !_labels_i.empty() && !_data_i.empty());
|
||||
if(_labels_i.cols != 1)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "labels should be a column matrix" );
|
||||
CV_Error( cv::Error::StsBadArg, "labels should be a column matrix" );
|
||||
}
|
||||
if(_data_i.type() != CV_32FC1 || _labels_i.type() != CV_32FC1)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "data and labels must be a floating point matrix" );
|
||||
CV_Error( cv::Error::StsBadArg, "data and labels must be a floating point matrix" );
|
||||
}
|
||||
if(_labels_i.rows != _data_i.rows)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "number of rows in data and labels should be equal" );
|
||||
CV_Error( cv::Error::StsBadArg, "number of rows in data and labels should be equal" );
|
||||
}
|
||||
|
||||
// class labels
|
||||
@@ -126,7 +126,7 @@ bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int)
|
||||
int num_classes = (int) this->forward_mapper.size();
|
||||
if(num_classes < 2)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "data should have at least 2 classes" );
|
||||
CV_Error( cv::Error::StsBadArg, "data should have at least 2 classes" );
|
||||
}
|
||||
|
||||
// add a column of ones to the data (bias/intercept term)
|
||||
@@ -174,7 +174,7 @@ bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int)
|
||||
this->learnt_thetas = thetas.clone();
|
||||
if( cvIsNaN( (double)sum(this->learnt_thetas)[0] ) )
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "check training parameters. Invalid training classifier" );
|
||||
CV_Error( cv::Error::StsBadArg, "check training parameters. Invalid training classifier" );
|
||||
}
|
||||
|
||||
// success
|
||||
@@ -187,7 +187,7 @@ float LogisticRegressionImpl::predict(InputArray samples, OutputArray results, i
|
||||
// check if learnt_mats array is populated
|
||||
if(!this->isTrained())
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "classifier should be trained first" );
|
||||
CV_Error( cv::Error::StsBadArg, "classifier should be trained first" );
|
||||
}
|
||||
|
||||
// coefficient matrix
|
||||
@@ -206,7 +206,7 @@ float LogisticRegressionImpl::predict(InputArray samples, OutputArray results, i
|
||||
Mat data = samples.getMat();
|
||||
if(data.type() != CV_32F)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "data must be of floating type" );
|
||||
CV_Error( cv::Error::StsBadArg, "data must be of floating type" );
|
||||
}
|
||||
|
||||
// add a column of ones to the data (bias/intercept term)
|
||||
@@ -327,7 +327,7 @@ double LogisticRegressionImpl::compute_cost(const Mat& _data, const Mat& _labels
|
||||
|
||||
if(cvIsNaN( cost ) == 1)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "check training parameters. Invalid training classifier" );
|
||||
CV_Error( cv::Error::StsBadArg, "check training parameters. Invalid training classifier" );
|
||||
}
|
||||
|
||||
return cost;
|
||||
@@ -398,12 +398,12 @@ Mat LogisticRegressionImpl::batch_gradient_descent(const Mat& _data, const Mat&
|
||||
// implements batch gradient descent
|
||||
if(this->params.alpha<=0)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "check training parameters (learning rate) for the classifier" );
|
||||
CV_Error( cv::Error::StsBadArg, "check training parameters (learning rate) for the classifier" );
|
||||
}
|
||||
|
||||
if(this->params.num_iters <= 0)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "number of iterations cannot be zero or a negative number" );
|
||||
CV_Error( cv::Error::StsBadArg, "number of iterations cannot be zero or a negative number" );
|
||||
}
|
||||
|
||||
int llambda = 0;
|
||||
@@ -439,12 +439,12 @@ Mat LogisticRegressionImpl::mini_batch_gradient_descent(const Mat& _data, const
|
||||
|
||||
if(this->params.mini_batch_size <= 0 || this->params.alpha == 0)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "check training parameters for the classifier" );
|
||||
CV_Error( cv::Error::StsBadArg, "check training parameters for the classifier" );
|
||||
}
|
||||
|
||||
if(this->params.num_iters <= 0)
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "number of iterations cannot be zero or a negative number" );
|
||||
CV_Error( cv::Error::StsBadArg, "number of iterations cannot be zero or a negative number" );
|
||||
}
|
||||
|
||||
Mat theta_p = _init_theta.clone();
|
||||
@@ -551,7 +551,7 @@ void LogisticRegressionImpl::write(FileStorage& fs) const
|
||||
// check if open
|
||||
if(fs.isOpened() == 0)
|
||||
{
|
||||
CV_Error(CV_StsBadArg,"file can't open. Check file path");
|
||||
CV_Error(cv::Error::StsBadArg,"file can't open. Check file path");
|
||||
}
|
||||
writeFormat(fs);
|
||||
string desc = "Logistic Regression Classifier";
|
||||
@@ -574,7 +574,7 @@ void LogisticRegressionImpl::read(const FileNode& fn)
|
||||
// check if empty
|
||||
if(fn.empty())
|
||||
{
|
||||
CV_Error( CV_StsBadArg, "empty FileNode object" );
|
||||
CV_Error( cv::Error::StsBadArg, "empty FileNode object" );
|
||||
}
|
||||
|
||||
this->params.alpha = (double)fn["alpha"];
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
norm(var_idx, __var_idx, NORM_INF) != 0 ||
|
||||
cls_labels.size() != __cls_labels.size() ||
|
||||
norm(cls_labels, __cls_labels, NORM_INF) != 0 )
|
||||
CV_Error( CV_StsBadArg,
|
||||
CV_Error( cv::Error::StsBadArg,
|
||||
"The new training data is inconsistent with the original training data; varIdx and the class labels should be the same" );
|
||||
}
|
||||
|
||||
@@ -312,11 +312,11 @@ public:
|
||||
bool rawOutput = (flags & RAW_OUTPUT) != 0;
|
||||
|
||||
if( samples.type() != CV_32F || samples.cols != nallvars )
|
||||
CV_Error( CV_StsBadArg,
|
||||
CV_Error( cv::Error::StsBadArg,
|
||||
"The input samples must be 32f matrix with the number of columns = nallvars" );
|
||||
|
||||
if( (samples.rows > 1) && (! _results.needed()) )
|
||||
CV_Error( CV_StsNullPtr,
|
||||
CV_Error( cv::Error::StsNullPtr,
|
||||
"When the number of input samples is >1, the output vector of results must be passed" );
|
||||
|
||||
if( _results.needed() )
|
||||
@@ -388,7 +388,7 @@ public:
|
||||
fn["var_all"] >> nallvars;
|
||||
|
||||
if( nallvars <= 0 )
|
||||
CV_Error( CV_StsParseError,
|
||||
CV_Error( cv::Error::StsParseError,
|
||||
"The field \"var_count\" of NBayes classifier is missing or non-positive" );
|
||||
|
||||
fn["var_idx"] >> var_idx;
|
||||
@@ -397,7 +397,7 @@ public:
|
||||
int nclasses = (int)cls_labels.total(), i;
|
||||
|
||||
if( cls_labels.empty() || nclasses < 1 )
|
||||
CV_Error( CV_StsParseError, "No or invalid \"cls_labels\" in NBayes classifier" );
|
||||
CV_Error( cv::Error::StsParseError, "No or invalid \"cls_labels\" in NBayes classifier" );
|
||||
|
||||
FileNodeIterator
|
||||
count_it = fn["count"].begin(),
|
||||
|
||||
@@ -131,13 +131,13 @@ namespace ml
|
||||
inline void setMaxCategories(int val)
|
||||
{
|
||||
if( val < 2 )
|
||||
CV_Error( CV_StsOutOfRange, "max_categories should be >= 2" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "max_categories should be >= 2" );
|
||||
maxCategories = std::min(val, 15 );
|
||||
}
|
||||
inline void setMaxDepth(int val)
|
||||
{
|
||||
if( val < 0 )
|
||||
CV_Error( CV_StsOutOfRange, "max_depth should be >= 0" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "max_depth should be >= 0" );
|
||||
maxDepth = std::min( val, 25 );
|
||||
}
|
||||
inline void setMinSampleCount(int val)
|
||||
@@ -147,11 +147,11 @@ namespace ml
|
||||
inline void setCVFolds(int val)
|
||||
{
|
||||
if( val < 0 )
|
||||
CV_Error( CV_StsOutOfRange,
|
||||
CV_Error( cv::Error::StsOutOfRange,
|
||||
"params.CVFolds should be =0 (the tree is not pruned) "
|
||||
"or n>0 (tree is pruned using n-fold cross-validation)" );
|
||||
if(val > 1)
|
||||
CV_Error( CV_StsNotImplemented,
|
||||
CV_Error( cv::Error::StsNotImplemented,
|
||||
"tree pruning using cross-validation is not implemented."
|
||||
"Set CVFolds to 1");
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace ml
|
||||
inline void setRegressionAccuracy(float val)
|
||||
{
|
||||
if( val < 0 )
|
||||
CV_Error( CV_StsOutOfRange, "params.regression_accuracy should be >= 0" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "params.regression_accuracy should be >= 0" );
|
||||
regressionAccuracy = val;
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
if( roots.empty() )
|
||||
CV_Error( CV_StsBadArg, "RTrees have not been trained" );
|
||||
CV_Error( cv::Error::StsBadArg, "RTrees have not been trained" );
|
||||
|
||||
writeFormat(fs);
|
||||
writeParams(fs);
|
||||
|
||||
+23
-23
@@ -95,11 +95,11 @@ const int QFLOAT_TYPE = DataDepth<Qfloat>::value;
|
||||
static void checkParamGrid(const ParamGrid& pg)
|
||||
{
|
||||
if( pg.minVal > pg.maxVal )
|
||||
CV_Error( CV_StsBadArg, "Lower bound of the grid must be less then the upper one" );
|
||||
CV_Error( cv::Error::StsBadArg, "Lower bound of the grid must be less then the upper one" );
|
||||
if( pg.minVal < DBL_EPSILON )
|
||||
CV_Error( CV_StsBadArg, "Lower bound of the grid must be positive" );
|
||||
CV_Error( cv::Error::StsBadArg, "Lower bound of the grid must be positive" );
|
||||
if( pg.logStep < 1. + FLT_EPSILON )
|
||||
CV_Error( CV_StsBadArg, "Grid step must greater than 1" );
|
||||
CV_Error( cv::Error::StsBadArg, "Grid step must greater than 1" );
|
||||
}
|
||||
|
||||
// SVM training parameters
|
||||
@@ -325,7 +325,7 @@ public:
|
||||
calc_intersec(vcount, var_count, vecs, another, results);
|
||||
break;
|
||||
default:
|
||||
CV_Error(CV_StsBadArg, "Unknown kernel type");
|
||||
CV_Error(cv::Error::StsBadArg, "Unknown kernel type");
|
||||
}
|
||||
const Qfloat max_val = (Qfloat)(FLT_MAX*1e-3);
|
||||
for( int j = 0; j < vcount; j++ )
|
||||
@@ -410,7 +410,7 @@ ParamGrid SVM::getDefaultGrid( int param_id )
|
||||
grid.logStep = 7; // total iterations = 3
|
||||
}
|
||||
else
|
||||
cvError( CV_StsBadArg, "SVM::getDefaultGrid", "Invalid type of parameter "
|
||||
cvError( cv::Error::StsBadArg, "SVM::getDefaultGrid", "Invalid type of parameter "
|
||||
"(use one of SVM::C, SVM::GAMMA et al.)", __FILE__, __LINE__ );
|
||||
return grid;
|
||||
}
|
||||
@@ -1297,12 +1297,12 @@ public:
|
||||
if( kernelType != LINEAR && kernelType != POLY &&
|
||||
kernelType != SIGMOID && kernelType != RBF &&
|
||||
kernelType != INTER && kernelType != CHI2)
|
||||
CV_Error( CV_StsBadArg, "Unknown/unsupported kernel type" );
|
||||
CV_Error( cv::Error::StsBadArg, "Unknown/unsupported kernel type" );
|
||||
|
||||
if( kernelType == LINEAR )
|
||||
params.gamma = 1;
|
||||
else if( params.gamma <= 0 )
|
||||
CV_Error( CV_StsOutOfRange, "gamma parameter of the kernel must be positive" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "gamma parameter of the kernel must be positive" );
|
||||
|
||||
if( kernelType != SIGMOID && kernelType != POLY )
|
||||
params.coef0 = 0;
|
||||
@@ -1310,14 +1310,14 @@ public:
|
||||
if( kernelType != POLY )
|
||||
params.degree = 0;
|
||||
else if( params.degree <= 0 )
|
||||
CV_Error( CV_StsOutOfRange, "The kernel parameter <degree> must be positive" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "The kernel parameter <degree> must be positive" );
|
||||
|
||||
kernel = makePtr<SVMKernelImpl>(params);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!kernel)
|
||||
CV_Error( CV_StsBadArg, "Custom kernel is not set" );
|
||||
CV_Error( cv::Error::StsBadArg, "Custom kernel is not set" );
|
||||
}
|
||||
|
||||
int svmType = params.svmType;
|
||||
@@ -1325,22 +1325,22 @@ public:
|
||||
if( svmType != C_SVC && svmType != NU_SVC &&
|
||||
svmType != ONE_CLASS && svmType != EPS_SVR &&
|
||||
svmType != NU_SVR )
|
||||
CV_Error( CV_StsBadArg, "Unknown/unsupported SVM type" );
|
||||
CV_Error( cv::Error::StsBadArg, "Unknown/unsupported SVM type" );
|
||||
|
||||
if( svmType == ONE_CLASS || svmType == NU_SVC )
|
||||
params.C = 0;
|
||||
else if( params.C <= 0 )
|
||||
CV_Error( CV_StsOutOfRange, "The parameter C must be positive" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "The parameter C must be positive" );
|
||||
|
||||
if( svmType == C_SVC || svmType == EPS_SVR )
|
||||
params.nu = 0;
|
||||
else if( params.nu <= 0 || params.nu >= 1 )
|
||||
CV_Error( CV_StsOutOfRange, "The parameter nu must be between 0 and 1" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "The parameter nu must be between 0 and 1" );
|
||||
|
||||
if( svmType != EPS_SVR )
|
||||
params.p = 0;
|
||||
else if( params.p <= 0 )
|
||||
CV_Error( CV_StsOutOfRange, "The parameter p must be positive" );
|
||||
CV_Error( cv::Error::StsOutOfRange, "The parameter p must be positive" );
|
||||
|
||||
if( svmType != C_SVC )
|
||||
params.classWeights.release();
|
||||
@@ -1431,7 +1431,7 @@ public:
|
||||
if( (cw.cols != 1 && cw.rows != 1) ||
|
||||
(int)cw.total() != class_count ||
|
||||
(cw.type() != CV_32F && cw.type() != CV_64F) )
|
||||
CV_Error( CV_StsBadArg, "params.class_weights must be 1d floating-point vector "
|
||||
CV_Error( cv::Error::StsBadArg, "params.class_weights must be 1d floating-point vector "
|
||||
"containing as many elements as the number of classes" );
|
||||
|
||||
cw.convertTo(class_weights, CV_64F, params.C);
|
||||
@@ -1446,7 +1446,7 @@ public:
|
||||
|
||||
//check that while cross-validation there were the samples from all the classes
|
||||
if ((int)class_ranges.size() < class_count + 1)
|
||||
CV_Error( CV_StsBadArg, "While cross-validation one or more of the classes have "
|
||||
CV_Error( cv::Error::StsBadArg, "While cross-validation one or more of the classes have "
|
||||
"been fell out of the sample. Try to reduce <Params::k_fold>" );
|
||||
|
||||
if( svmType == NU_SVC )
|
||||
@@ -1620,7 +1620,7 @@ public:
|
||||
{
|
||||
responses = data->getTrainNormCatResponses();
|
||||
if( responses.empty() )
|
||||
CV_Error(CV_StsBadArg, "in the case of classification problem the responses must be categorical; "
|
||||
CV_Error(cv::Error::StsBadArg, "in the case of classification problem the responses must be categorical; "
|
||||
"either specify varType when creating TrainData, or pass integer responses");
|
||||
class_labels = data->getClassLabels();
|
||||
}
|
||||
@@ -1969,7 +1969,7 @@ public:
|
||||
}
|
||||
}
|
||||
else
|
||||
CV_Error( CV_StsBadArg, "INTERNAL ERROR: Unknown SVM type, "
|
||||
CV_Error( cv::Error::StsBadArg, "INTERNAL ERROR: Unknown SVM type, "
|
||||
"the SVM structure is probably corrupted" );
|
||||
}
|
||||
|
||||
@@ -2112,7 +2112,7 @@ public:
|
||||
int class_count = !class_labels.empty() ? (int)class_labels.total() :
|
||||
params.svmType == ONE_CLASS ? 1 : 0;
|
||||
if( !isTrained() )
|
||||
CV_Error( CV_StsParseError, "SVM model data is invalid, check sv_count, var_* and class_count tags" );
|
||||
CV_Error( cv::Error::StsParseError, "SVM model data is invalid, check sv_count, var_* and class_count tags" );
|
||||
|
||||
writeFormat(fs);
|
||||
write_params( fs );
|
||||
@@ -2197,11 +2197,11 @@ public:
|
||||
svm_type_str == "NU_SVR" ? NU_SVR : -1;
|
||||
|
||||
if( svmType < 0 )
|
||||
CV_Error( CV_StsParseError, "Missing or invalid SVM type" );
|
||||
CV_Error( cv::Error::StsParseError, "Missing or invalid SVM type" );
|
||||
|
||||
FileNode kernel_node = fn["kernel"];
|
||||
if( kernel_node.empty() )
|
||||
CV_Error( CV_StsParseError, "SVM kernel tag is not found" );
|
||||
CV_Error( cv::Error::StsParseError, "SVM kernel tag is not found" );
|
||||
|
||||
String kernel_type_str = (String)kernel_node["type"];
|
||||
int kernelType =
|
||||
@@ -2213,7 +2213,7 @@ public:
|
||||
kernel_type_str == "INTER" ? INTER : CUSTOM;
|
||||
|
||||
if( kernelType == CUSTOM )
|
||||
CV_Error( CV_StsParseError, "Invalid SVM kernel type (or custom kernel)" );
|
||||
CV_Error( cv::Error::StsParseError, "Invalid SVM kernel type (or custom kernel)" );
|
||||
|
||||
_params.svmType = svmType;
|
||||
_params.kernelType = kernelType;
|
||||
@@ -2253,7 +2253,7 @@ public:
|
||||
int class_count = (int)fn["class_count"];
|
||||
|
||||
if( sv_total <= 0 || var_count <= 0 )
|
||||
CV_Error( CV_StsParseError, "SVM model data is invalid, check sv_count, var_* and class_count tags" );
|
||||
CV_Error( cv::Error::StsParseError, "SVM model data is invalid, check sv_count, var_* and class_count tags" );
|
||||
|
||||
FileNode m = fn["class_labels"];
|
||||
if( !m.empty() )
|
||||
@@ -2263,7 +2263,7 @@ public:
|
||||
m >> params.classWeights;
|
||||
|
||||
if( class_count > 1 && (class_labels.empty() || (int)class_labels.total() != class_count))
|
||||
CV_Error( CV_StsParseError, "Array of class labels is missing or invalid" );
|
||||
CV_Error( cv::Error::StsParseError, "Array of class labels is missing or invalid" );
|
||||
|
||||
// read support vectors
|
||||
FileNode sv_node = fn["support_vectors"];
|
||||
|
||||
@@ -375,7 +375,7 @@ bool SVMSGDImpl::isTrained() const
|
||||
void SVMSGDImpl::write(FileStorage& fs) const
|
||||
{
|
||||
if( !isTrained() )
|
||||
CV_Error( CV_StsParseError, "SVMSGD model data is invalid, it hasn't been trained" );
|
||||
CV_Error( cv::Error::StsParseError, "SVMSGD model data is invalid, it hasn't been trained" );
|
||||
|
||||
writeFormat(fs);
|
||||
writeParams( fs );
|
||||
@@ -437,7 +437,7 @@ void SVMSGDImpl::readParams( const FileNode& fn )
|
||||
svmsgdTypeStr == "ASGD" ? ASGD : -1;
|
||||
|
||||
if( svmsgdType < 0 )
|
||||
CV_Error( CV_StsParseError, "Missing or invalid SVMSGD type" );
|
||||
CV_Error( cv::Error::StsParseError, "Missing or invalid SVMSGD type" );
|
||||
|
||||
params.svmsgdType = svmsgdType;
|
||||
|
||||
@@ -447,7 +447,7 @@ void SVMSGDImpl::readParams( const FileNode& fn )
|
||||
marginTypeStr == "HARD_MARGIN" ? HARD_MARGIN : -1;
|
||||
|
||||
if( marginType < 0 )
|
||||
CV_Error( CV_StsParseError, "Missing or invalid margin type" );
|
||||
CV_Error( cv::Error::StsParseError, "Missing or invalid margin type" );
|
||||
|
||||
params.marginType = marginType;
|
||||
|
||||
@@ -517,7 +517,7 @@ void SVMSGDImpl::setOptimalParameters(int svmsgdType, int marginType)
|
||||
break;
|
||||
|
||||
default:
|
||||
CV_Error( CV_StsParseError, "SVMSGD model data is invalid" );
|
||||
CV_Error( cv::Error::StsParseError, "SVMSGD model data is invalid" );
|
||||
}
|
||||
}
|
||||
} //ml
|
||||
|
||||
@@ -60,13 +60,13 @@ void createConcentricSpheresTestSet( int num_samples, int num_features, int num_
|
||||
OutputArray _samples, OutputArray _responses)
|
||||
{
|
||||
if( num_samples < 1 )
|
||||
CV_Error( CV_StsBadArg, "num_samples parameter must be positive" );
|
||||
CV_Error( cv::Error::StsBadArg, "num_samples parameter must be positive" );
|
||||
|
||||
if( num_features < 1 )
|
||||
CV_Error( CV_StsBadArg, "num_features parameter must be positive" );
|
||||
CV_Error( cv::Error::StsBadArg, "num_features parameter must be positive" );
|
||||
|
||||
if( num_classes < 1 )
|
||||
CV_Error( CV_StsBadArg, "num_classes parameter must be positive" );
|
||||
CV_Error( cv::Error::StsBadArg, "num_classes parameter must be positive" );
|
||||
|
||||
int i, cur_class;
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ int DTreesImpl::addNodeAndTrySplit( int parent, const vector<int>& sidx )
|
||||
{
|
||||
node.defaultDir = calcDir( node.split, sidx, sleft, sright );
|
||||
if( params.useSurrogates )
|
||||
CV_Error( CV_StsNotImplemented, "surrogate splits are not implemented yet");
|
||||
CV_Error( cv::Error::StsNotImplemented, "surrogate splits are not implemented yet");
|
||||
|
||||
int left = addNodeAndTrySplit( nidx, sleft );
|
||||
int right = addNodeAndTrySplit( nidx, sright );
|
||||
@@ -1445,7 +1445,7 @@ float DTreesImpl::predictTrees( const Range& range, const Mat& sample, int flags
|
||||
|
||||
int ival = cvRound(val);
|
||||
if( ival != val )
|
||||
CV_Error( CV_StsBadArg,
|
||||
CV_Error( cv::Error::StsBadArg,
|
||||
"one of input categorical variable is not an integer" );
|
||||
|
||||
CV_Assert(cmap != NULL);
|
||||
|
||||
Reference in New Issue
Block a user