forked from beetleskin/hrf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CRForest.hpp
executable file
·54 lines (44 loc) · 1.75 KB
/
CRForest.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Training Procedures (training_mode):
* 0: the training mode=0 does the InfGain over all classes
* 1: transforms all the positive class_ids into different labels and does multi-class training with InfGain/nlabels + InfGainBG
* 3: also transforms all the positive class ids into one label and does all-against-background training with InfGainBG
**/
#pragma once
#include "CRTree.hpp"
#define timer fubar
#include <boost/progress.hpp>
#undef timer
#include <boost/timer/timer.hpp>
#include <memory>
#include <vector>
using namespace std;
class CRForest {
public:
typedef shared_ptr<CRForest> Ptr;
typedef shared_ptr<CRForest const> ConstPtr;
/* Trees */
vector<CRTree::Ptr> vTrees_;
/* training labels to use for detection */
vector<int> use_labels_;
/* decide what kind of training procedures to take */
int training_mode;
CRForest(int num_trees = 0);
~CRForest();
void GetClassID(vector<vector<int> > &id) const;
unsigned int GetDepth() const;
bool GetHierarchy(vector<HNode> &hierarchy) const;
unsigned int GetNumLabels() const;
void SetTrees(int num_trees);
int GetSize() const;
void SetTrainingLabelsForDetection(vector<int> &class_selector);
void GetTrainingLabelsForDetection(vector<int> &class_selector);
// Regression
void regression(vector<const LeafNode *> &result, vector<Mat> &vImg, int x, int y) const;
// Training
void trainForest(int min_s, int max_d, CvRNG *pRNG, const CRPatch &TrData, int samples, vector<int> &id, float scale_tree = 1.0f);
// IO functions
void saveForest(const char *filename, unsigned int offset = 0);
bool loadForest(const char *filename, unsigned int offset = 0);
void loadHierarchy(const char *hierarchy, unsigned int offset = 0);
};