| 63 | } |
| 64 | |
| 65 | static void storeRecursive(QDataStream &stream, const Node *node, int maxCatCount) |
| 66 | { |
| 67 | bool hasChildren = node->left ? true : false; |
| 68 | stream << hasChildren; |
| 69 | |
| 70 | if (!hasChildren) |
| 71 | stream << node->value; |
| 72 | else { |
| 73 | if (maxCatCount > 0) |
| 74 | for (int i = 0; i < (maxCatCount + 31)/32; i++) |
| 75 | stream << node->subset[i]; |
| 76 | else |
| 77 | stream << node->threshold; |
| 78 | |
| 79 | stream << node->featureIdx; |
| 80 | |
| 81 | storeRecursive(stream, node->left, maxCatCount); |
| 82 | storeRecursive(stream, node->right, maxCatCount); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /*! |
| 87 | * \brief A classification wrapper on OpenCV's CvBoost class. It uses CvBoost for training a boosted forest and then performs classification using the trained nodes. |