Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions apps/traincascade/boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ static CvMat* cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, b
int* dsti;

if( !CV_IS_MAT(idx_arr) )
CV_ERROR( CV_StsBadArg, "Invalid index array" );
CV_ERROR( cv::Error::StsBadArg, "Invalid index array" );

if( idx_arr->rows != 1 && idx_arr->cols != 1 )
CV_ERROR( CV_StsBadSize, "the index array must be 1-dimensional" );
CV_ERROR( cv::Error::StsBadSize, "the index array must be 1-dimensional" );

idx_total = idx_arr->rows + idx_arr->cols - 1;
srcb = idx_arr->data.ptr;
Expand All @@ -105,20 +105,20 @@ static CvMat* cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, b
// idx_arr is array of 1's and 0's -
// i.e. it is a mask of the selected components
if( idx_total != data_arr_size )
CV_ERROR( CV_StsUnmatchedSizes,
CV_ERROR( cv::Error::StsUnmatchedSizes,
"Component mask should contain as many elements as the total number of input variables" );

for( i = 0; i < idx_total; i++ )
idx_selected += srcb[i*step] != 0;

if( idx_selected == 0 )
CV_ERROR( CV_StsOutOfRange, "No components/input_variables is selected!" );
CV_ERROR( cv::Error::StsOutOfRange, "No components/input_variables is selected!" );

break;
case CV_32SC1:
// idx_arr is array of integer indices of selected components
if( idx_total > data_arr_size )
CV_ERROR( CV_StsOutOfRange,
CV_ERROR( cv::Error::StsOutOfRange,
"index array may not contain more elements than the total number of input variables" );
idx_selected = idx_total;
// check if sorted already
Expand All @@ -134,7 +134,7 @@ static CvMat* cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, b
}
break;
default:
CV_ERROR( CV_StsUnsupportedFormat, "Unsupported index array data type "
CV_ERROR( cv::Error::StsUnsupportedFormat, "Unsupported index array data type "
"(it should be 8uC1, 8sC1 or 32sC1)" );
}

Expand All @@ -156,13 +156,13 @@ static CvMat* cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, b
qsort( dsti, idx_total, sizeof(dsti[0]), icvCmpIntegers );

if( dsti[0] < 0 || dsti[idx_total-1] >= data_arr_size )
CV_ERROR( CV_StsOutOfRange, "the index array elements are out of range" );
CV_ERROR( cv::Error::StsOutOfRange, "the index array elements are out of range" );

if( check_for_duplicates )
{
for( i = 1; i < idx_total; i++ )
if( dsti[i] <= dsti[i-1] )
CV_ERROR( CV_StsBadArg, "There are duplicated index array elements" );
CV_ERROR( cv::Error::StsBadArg, "There are duplicated index array elements" );
}
}

Expand Down Expand Up @@ -218,7 +218,7 @@ bool CvCascadeBoostParams::read( const FileNode &node )
!boostTypeStr.compare( CC_LOGIT_BOOST ) ? CvBoost::LOGIT :
!boostTypeStr.compare( CC_GENTLE_BOOST ) ? CvBoost::GENTLE : -1;
if (boost_type == -1)
CV_Error( CV_StsBadArg, "unsupported Boost type" );
CV_Error( cv::Error::StsBadArg, "unsupported Boost type" );
node[CC_MINHITRATE] >> minHitRate;
node[CC_MAXFALSEALARM] >> maxFalseAlarm;
node[CC_TRIM_RATE] >> weight_trim_rate ;
Expand All @@ -228,7 +228,7 @@ bool CvCascadeBoostParams::read( const FileNode &node )
maxFalseAlarm <= 0 || maxFalseAlarm > 1 ||
weight_trim_rate <= 0 || weight_trim_rate > 1 ||
max_depth <= 0 || weak_count <= 0 )
CV_Error( CV_StsBadArg, "bad parameters range");
CV_Error( cv::Error::StsBadArg, "bad parameters range");
return true;
}

Expand Down Expand Up @@ -309,7 +309,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
bool isMakeRootCopy = true;

if( !data_root )
CV_Error( CV_StsError, "No training data has been set" );
CV_Error( cv::Error::StsError, "No training data has been set" );

if( _subsample_idx )
{
Expand Down Expand Up @@ -547,7 +547,7 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
// TODO: check responses: elements must be 0 or 1

if( _precalcValBufSize < 0 || _precalcIdxBufSize < 0)
CV_Error( CV_StsOutOfRange, "_numPrecalcVal and _numPrecalcIdx must be positive or 0" );
CV_Error( cv::Error::StsOutOfRange, "_numPrecalcVal and _numPrecalcIdx must be positive or 0" );

var_count = var_all = featureEvaluator->getNumFeatures() * featureEvaluator->getFeatureSize();
sample_count = _numSamples;
Expand Down Expand Up @@ -602,7 +602,7 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat

if ((uint64)effective_buf_width * (uint64)effective_buf_height != effective_buf_size)
{
CV_Error(CV_StsBadArg, "The memory buffer cannot be allocated since its size exceeds integer fields limit");
CV_Error(cv::Error::StsBadArg, "The memory buffer cannot be allocated since its size exceeds integer fields limit");
}

if ( is_buf_16u )
Expand Down Expand Up @@ -914,7 +914,7 @@ CvDTreeNode* CvCascadeBoostTree::predict( int sampleIdx ) const
{
CvDTreeNode* node = root;
if( !node )
CV_Error( CV_StsError, "The tree has not been trained yet" );
CV_Error( cv::Error::StsError, "The tree has not been trained yet" );

if ( ((CvCascadeBoostTrainData*)data)->featureEvaluator->getMaxCatCount() == 0 ) // ordered
{
Expand Down
4 changes: 2 additions & 2 deletions apps/traincascade/cascadeclassifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
double time = (double)getTickCount();

if( _cascadeDirName.empty() || _posFilename.empty() || _negFilename.empty() )
CV_Error( CV_StsBadArg, "_cascadeDirName or _bgfileName or _vecFileName is NULL" );
CV_Error( cv::Error::StsBadArg, "_cascadeDirName or _bgfileName or _vecFileName is NULL" );

string dirName;
if (_cascadeDirName.find_last_of("/\\") == (_cascadeDirName.length() - 1) )
Expand Down Expand Up @@ -452,7 +452,7 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
//char buf[256];
CvSeq* weak;
if ( cascadeParams.featureType != CvFeatureParams::HAAR )
CV_Error( CV_StsBadFunc, "old file format is used for Haar-like features only");
CV_Error( cv::Error::StsBadFunc, "old file format is used for Haar-like features only");
fs << "{:" ICV_HAAR_TYPE_ID;
fs << ICV_HAAR_SIZE_NAME << "[:" << cascadeParams.winSize.width <<
cascadeParams.winSize.height << "]";
Expand Down
8 changes: 4 additions & 4 deletions apps/traincascade/imagestorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool CvCascadeImageReader::PosReader::create( const string _filename )
fread( &vecSize, sizeof( vecSize ), 1, file ) != 1 ||
fread( &tmp, sizeof( tmp ), 1, file ) != 1 ||
fread( &tmp, sizeof( tmp ), 1, file ) != 1 )
CV_Error_( CV_StsParseError, ("wrong file format for %s\n", _filename.c_str()) );
CV_Error_( cv::Error::StsParseError, ("wrong file format for %s\n", _filename.c_str()) );
base = sizeof( count ) + sizeof( vecSize ) + 2*sizeof( tmp );
if( feof( file ) )
return false;
Expand All @@ -154,14 +154,14 @@ bool CvCascadeImageReader::PosReader::get( Mat &_img )
uchar tmp = 0;
size_t elements_read = fread( &tmp, sizeof( tmp ), 1, file );
if( elements_read != 1 )
CV_Error( CV_StsBadArg, "Can not get new positive sample. The most possible reason is "
CV_Error( cv::Error::StsBadArg, "Can not get new positive sample. The most possible reason is "
"insufficient count of samples in given vec-file.\n");
elements_read = fread( vec, sizeof( vec[0] ), vecSize, file );
if( elements_read != (size_t)(vecSize) )
CV_Error( CV_StsBadArg, "Can not get new positive sample. Seems that vec-file has incorrect structure.\n");
CV_Error( cv::Error::StsBadArg, "Can not get new positive sample. Seems that vec-file has incorrect structure.\n");

if( feof( file ) || last++ >= count )
CV_Error( CV_StsBadArg, "Can not get new positive sample. vec-file is over.\n");
CV_Error( cv::Error::StsBadArg, "Can not get new positive sample. vec-file is over.\n");

for( int r = 0; r < _img.rows; r++ )
{
Expand Down
28 changes: 14 additions & 14 deletions apps/traincascade/old_ml_boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ CvBoost::set_params( const CvBoostParams& _params )
params = _params;
if( params.boost_type != DISCRETE && params.boost_type != REAL &&
params.boost_type != LOGIT && params.boost_type != GENTLE )
CV_ERROR( CV_StsBadArg, "Unknown/unsupported boosting type" );
CV_ERROR( cv::Error::StsBadArg, "Unknown/unsupported boosting type" );

params.weak_count = MAX( params.weak_count, 1 );
params.weight_trim_rate = MAX( params.weight_trim_rate, 0. );
Expand Down Expand Up @@ -1045,7 +1045,7 @@ CvBoost::train( const CvMat* _train_data, int _tflag,
_sample_idx, _var_type, _missing_mask, _params, true, true );

if( data->get_num_classes() != 2 )
CV_ERROR( CV_StsNotImplemented,
CV_ERROR( cv::Error::StsNotImplemented,
"Boosted trees can only be used for 2-class classification." );
CV_CALL( storage = cvCreateMemStorage() );
weak = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvBoostTree*), storage );
Expand Down Expand Up @@ -1482,7 +1482,7 @@ CvBoost::get_active_vars( bool absolute_idx )
__BEGIN__;

if( !weak )
CV_ERROR( CV_StsError, "The boosted tree ensemble has not been trained yet" );
CV_ERROR( cv::Error::StsError, "The boosted tree ensemble has not been trained yet" );

if( !active_vars || !active_vars_abs )
{
Expand Down Expand Up @@ -1612,13 +1612,13 @@ CvBoost::predict( const CvMat* _sample, const CvMat* _missing,
const float* sample_data;

if( !weak )
CV_Error( CV_StsError, "The boosted tree ensemble has not been trained yet" );
CV_Error( cv::Error::StsError, "The boosted tree ensemble has not been trained yet" );

if( !CV_IS_MAT(_sample) || CV_MAT_TYPE(_sample->type) != CV_32FC1 ||
(_sample->cols != 1 && _sample->rows != 1) ||
(_sample->cols + _sample->rows - 1 != data->var_all && !raw_mode) ||
(active_vars && _sample->cols + _sample->rows - 1 != active_vars->cols && raw_mode) )
CV_Error( CV_StsBadArg,
CV_Error( cv::Error::StsBadArg,
"the input sample must be 1d floating-point vector with the same "
"number of elements as the total number of variables or "
"as the number of variables used for training" );
Expand All @@ -1627,7 +1627,7 @@ CvBoost::predict( const CvMat* _sample, const CvMat* _missing,
{
if( !CV_IS_MAT(_missing) || !CV_IS_MASK_ARR(_missing) ||
!CV_ARE_SIZES_EQ(_missing, _sample) )
CV_Error( CV_StsBadArg,
CV_Error( cv::Error::StsBadArg,
"the missing data mask must be 8-bit vector of the same size as input sample" );
}

Expand All @@ -1644,7 +1644,7 @@ CvBoost::predict( const CvMat* _sample, const CvMat* _missing,
CV_MAT_TYPE(weak_responses->type) != CV_32FC1 ||
(weak_responses->cols != 1 && weak_responses->rows != 1) ||
weak_responses->cols + weak_responses->rows - 1 != weak_count )
CV_Error( CV_StsBadArg,
CV_Error( cv::Error::StsBadArg,
"The output matrix of weak classifier responses must be valid "
"floating-point vector of the same number of components as the length of input slice" );
wstep = CV_IS_MAT_CONT(weak_responses->type) ? 1 : weak_responses->step/sizeof(float);
Expand Down Expand Up @@ -1700,7 +1700,7 @@ CvBoost::predict( const CvMat* _sample, const CvMat* _missing,
c = a;
int ival = cvRound(val);
if ( (ival != val) && (!m) )
CV_Error( CV_StsBadArg,
CV_Error( cv::Error::StsBadArg,
"one of input categorical variable is not an integer" );

while( a < b )
Expand Down Expand Up @@ -1735,7 +1735,7 @@ CvBoost::predict( const CvMat* _sample, const CvMat* _missing,
else
{
if( !CV_IS_MAT_CONT(_sample->type & (_missing ? _missing->type : -1)) )
CV_Error( CV_StsBadArg, "In raw mode the input vectors must be continuous" );
CV_Error( cv::Error::StsBadArg, "In raw mode the input vectors must be continuous" );
}

cvStartReadSeq( weak, &reader );
Expand Down Expand Up @@ -1951,7 +1951,7 @@ void CvBoost::read_params( cv::FileNode& fnode )
params.boost_type = temp.empty() ? -1 : (int)temp;

if( params.boost_type < DISCRETE || params.boost_type > GENTLE )
CV_ERROR( CV_StsBadArg, "Unknown boosting type" );
CV_ERROR( cv::Error::StsBadArg, "Unknown boosting type" );

temp = fnode[ "splitting_criteria" ];
if( !temp.empty() && temp.isString() )
Expand All @@ -1966,7 +1966,7 @@ void CvBoost::read_params( cv::FileNode& fnode )
params.split_criteria = temp.empty() ? -1 : (int) temp;

if( params.split_criteria < DEFAULT || params.boost_type > SQERR )
CV_ERROR( CV_StsBadArg, "Unknown boosting type" );
CV_ERROR( cv::Error::StsBadArg, "Unknown boosting type" );

params.weak_count = (int) fnode[ "ntrees" ];
params.weight_trim_rate = (double)fnode["weight_trimming_rate"];
Expand Down Expand Up @@ -1996,13 +1996,13 @@ CvBoost::read( cv::FileNode& node )

trees_fnode = node[ "trees" ];
if( trees_fnode.empty() || !trees_fnode.isSeq() )
CV_ERROR( CV_StsParseError, "<trees> tag is missing" );
CV_ERROR( cv::Error::StsParseError, "<trees> tag is missing" );

reader = trees_fnode.begin();
ntrees = (int) trees_fnode.size();

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() );
Expand Down Expand Up @@ -2034,7 +2034,7 @@ CvBoost::write( cv::FileStorage& fs, const char* name ) const
fs.startWriteStruct( name, cv::FileNode::MAP, CV_TYPE_NAME_ML_BOOSTING );

if( !weak )
CV_ERROR( CV_StsBadArg, "The classifier has not been trained yet" );
CV_ERROR( cv::Error::StsBadArg, "The classifier has not been trained yet" );

write_params( fs );
fs.startWriteStruct( "trees", cv::FileNode::SEQ );
Expand Down
Loading