From 2c958b2598230e79188dec7a4da735e376b0536d Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Fri, 24 Jun 2011 12:25:52 +0000 Subject: [PATCH] Trunk: moved contructors implementations from .hpp to .cpp --- modules/ml/include/opencv2/ml/ml.hpp | 49 +++++++--------------------- modules/ml/src/rtrees.cpp | 20 ++++++++++++ modules/ml/src/tree.cpp | 17 ++++++++++ 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/modules/ml/include/opencv2/ml/ml.hpp b/modules/ml/include/opencv2/ml/ml.hpp index eacac664d..1229f72e1 100644 --- a/modules/ml/include/opencv2/ml/ml.hpp +++ b/modules/ml/include/opencv2/ml/ml.hpp @@ -744,23 +744,12 @@ struct CV_EXPORTS_W_MAP CvDTreeParams CV_PROP_RW float regression_accuracy; const float* priors; - CvDTreeParams() : max_categories(10), max_depth(INT_MAX), min_sample_count(10), - cv_folds(10), use_surrogates(true), use_1se_rule(true), - truncate_pruned_tree(true), regression_accuracy(0.01f), priors(0) - {} - - CvDTreeParams( int _max_depth, int _min_sample_count, - float _regression_accuracy, bool _use_surrogates, - int _max_categories, int _cv_folds, - bool _use_1se_rule, bool _truncate_pruned_tree, - const float* _priors ) : - max_categories(_max_categories), max_depth(_max_depth), - min_sample_count(_min_sample_count), cv_folds (_cv_folds), - use_surrogates(_use_surrogates), use_1se_rule(_use_1se_rule), - truncate_pruned_tree(_truncate_pruned_tree), - regression_accuracy(_regression_accuracy), - priors(_priors) - {} + CvDTreeParams(); + CvDTreeParams( int max_depth, int min_sample_count, + float regression_accuracy, bool use_surrogates, + int max_categories, int cv_folds, + bool use_1se_rule, bool truncate_pruned_tree, + const float* priors ); }; @@ -1016,26 +1005,12 @@ struct CV_EXPORTS_W_MAP CvRTParams : public CvDTreeParams CV_PROP_RW int nactive_vars; CV_PROP_RW CvTermCriteria term_crit; - CvRTParams() : CvDTreeParams( 5, 10, 0, false, 10, 0, false, false, 0 ), - calc_var_importance(false), nactive_vars(0) - { - term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 50, 0.1 ); - } - - CvRTParams( int _max_depth, int _min_sample_count, - float _regression_accuracy, bool _use_surrogates, - int _max_categories, const float* _priors, bool _calc_var_importance, - int _nactive_vars, int max_num_of_trees_in_the_forest, - float forest_accuracy, int termcrit_type ) : - CvDTreeParams( _max_depth, _min_sample_count, _regression_accuracy, - _use_surrogates, _max_categories, 0, - false, false, _priors ), - calc_var_importance(_calc_var_importance), - nactive_vars(_nactive_vars) - { - term_crit = cvTermCriteria(termcrit_type, - max_num_of_trees_in_the_forest, forest_accuracy); - } + CvRTParams(); + CvRTParams( int max_depth, int min_sample_count, + float regression_accuracy, bool use_surrogates, + int max_categories, const float* priors, bool calc_var_importance, + int nactive_vars, int max_num_of_trees_in_the_forest, + float forest_accuracy, int termcrit_type ); }; diff --git a/modules/ml/src/rtrees.cpp b/modules/ml/src/rtrees.cpp index 79ae66566..a1a13b018 100644 --- a/modules/ml/src/rtrees.cpp +++ b/modules/ml/src/rtrees.cpp @@ -190,6 +190,26 @@ void CvForestTree::read( CvFileStorage* _fs, CvFileNode* _node, ////////////////////////////////////////////////////////////////////////////////////////// // Random trees // ////////////////////////////////////////////////////////////////////////////////////////// +CvRTParams::CvRTParams() : CvDTreeParams( 5, 10, 0, false, 10, 0, false, false, 0 ), + calc_var_importance(false), nactive_vars(0) +{ + term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 50, 0.1 ); +} + +CvRTParams::CvRTParams( int _max_depth, int _min_sample_count, + float _regression_accuracy, bool _use_surrogates, + int _max_categories, const float* _priors, bool _calc_var_importance, + int _nactive_vars, int max_num_of_trees_in_the_forest, + float forest_accuracy, int termcrit_type ) : + CvDTreeParams( _max_depth, _min_sample_count, _regression_accuracy, + _use_surrogates, _max_categories, 0, + false, false, _priors ), + calc_var_importance(_calc_var_importance), + nactive_vars(_nactive_vars) +{ + term_crit = cvTermCriteria(termcrit_type, + max_num_of_trees_in_the_forest, forest_accuracy); +} CvRTrees::CvRTrees() { diff --git a/modules/ml/src/tree.cpp b/modules/ml/src/tree.cpp index 2df7ed390..371c717ab 100644 --- a/modules/ml/src/tree.cpp +++ b/modules/ml/src/tree.cpp @@ -1466,6 +1466,23 @@ void CvDTreeTrainData::read_params( CvFileStorage* fs, CvFileNode* node ) } /////////////////////// Decision Tree ///////////////////////// +CvDTreeParams::CvDTreeParams() : max_categories(10), max_depth(INT_MAX), min_sample_count(10), + cv_folds(10), use_surrogates(true), use_1se_rule(true), + truncate_pruned_tree(true), regression_accuracy(0.01f), priors(0) +{} + +CvDTreeParams::CvDTreeParams( int _max_depth, int _min_sample_count, + float _regression_accuracy, bool _use_surrogates, + int _max_categories, int _cv_folds, + bool _use_1se_rule, bool _truncate_pruned_tree, + const float* _priors ) : + max_categories(_max_categories), max_depth(_max_depth), + min_sample_count(_min_sample_count), cv_folds (_cv_folds), + use_surrogates(_use_surrogates), use_1se_rule(_use_1se_rule), + truncate_pruned_tree(_truncate_pruned_tree), + regression_accuracy(_regression_accuracy), + priors(_priors) +{} CvDTree::CvDTree() {