Commit b0f41b6e5a22f2b1eb08a77ea830c3784aec1596
1 parent
373069f6
Added parameter for termination criteria
Showing
1 changed file
with
12 additions
and
3 deletions
openbr/plugins/tree.cpp
| ... | ... | @@ -96,6 +96,7 @@ class ForestTransform : public Transform |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | protected: |
| 99 | + Q_ENUMS(TerminationCriteria) | |
| 99 | 100 | Q_PROPERTY(bool classification READ get_classification WRITE set_classification RESET reset_classification STORED false) |
| 100 | 101 | Q_PROPERTY(float splitPercentage READ get_splitPercentage WRITE set_splitPercentage RESET reset_splitPercentage STORED false) |
| 101 | 102 | Q_PROPERTY(int maxDepth READ get_maxDepth WRITE set_maxDepth RESET reset_maxDepth STORED false) |
| ... | ... | @@ -106,6 +107,14 @@ protected: |
| 106 | 107 | Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false) |
| 107 | 108 | Q_PROPERTY(QString outputVariable READ get_outputVariable WRITE set_outputVariable RESET reset_outputVariable STORED false) |
| 108 | 109 | Q_PROPERTY(bool weight READ get_weight WRITE set_weight RESET reset_weight STORED false) |
| 110 | + Q_PROPERTY(TerminationCriteria termCrit READ get_termCrit WRITE set_termCrit RESET reset_termCrit STORED false) | |
| 111 | + | |
| 112 | +public: | |
| 113 | + enum TerminationCriteria { Iter = CV_TERMCRIT_ITER, | |
| 114 | + EPS = CV_TERMCRIT_EPS, | |
| 115 | + Both = CV_TERMCRIT_EPS | CV_TERMCRIT_ITER}; | |
| 116 | + | |
| 117 | +protected: | |
| 109 | 118 | BR_PROPERTY(bool, classification, true) |
| 110 | 119 | BR_PROPERTY(float, splitPercentage, .01) |
| 111 | 120 | BR_PROPERTY(int, maxDepth, std::numeric_limits<int>::max()) |
| ... | ... | @@ -116,6 +125,7 @@ protected: |
| 116 | 125 | BR_PROPERTY(QString, inputVariable, "Label") |
| 117 | 126 | BR_PROPERTY(QString, outputVariable, "") |
| 118 | 127 | BR_PROPERTY(bool, weight, false) |
| 128 | + BR_PROPERTY(TerminationCriteria, termCrit, Iter) | |
| 119 | 129 | |
| 120 | 130 | CvRTrees forest; |
| 121 | 131 | |
| ... | ... | @@ -139,7 +149,6 @@ protected: |
| 139 | 149 | int nonZero = countNonZero(labels); |
| 140 | 150 | priors[0] = 1; |
| 141 | 151 | priors[1] = (float)(samples.rows-nonZero)/nonZero; |
| 142 | - qDebug() << priors[0] << priors[1] << (samples.rows-nonZero)/nonZero; | |
| 143 | 152 | } |
| 144 | 153 | |
| 145 | 154 | int minSamplesForSplit = data.size()*splitPercentage; |
| ... | ... | @@ -149,12 +158,12 @@ protected: |
| 149 | 158 | 0, |
| 150 | 159 | false, |
| 151 | 160 | 2, |
| 152 | - usePrior ? priors : 0, //priors | |
| 161 | + usePrior ? priors : 0, | |
| 153 | 162 | false, |
| 154 | 163 | 0, |
| 155 | 164 | maxTrees, |
| 156 | 165 | forestAccuracy, |
| 157 | - CV_TERMCRIT_ITER)); | |
| 166 | + termCrit)); | |
| 158 | 167 | |
| 159 | 168 | if (Globals->verbose) { |
| 160 | 169 | qDebug() << "Number of trees:" << forest.get_tree_count(); | ... | ... |