This repository has been archived by the owner on Nov 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CRForest.h
64 lines (47 loc) · 1.62 KB
/
CRForest.h
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
55
56
57
58
59
60
61
62
63
64
#pragma once
#ifndef CRForest_H
#define CRForest_H
#include "CRTree.h"
#include <stdio.h>
#include <vector>
class CRForest {
public:
// Constructor
CRForest(int trees = 0) {
vTrees.resize(trees);
}
// Destructor
~CRForest() {
for(std::vector<CRTree*>::iterator it = vTrees.begin(); it != vTrees.end(); ++it)
delete *it; // delete pointers
vTrees.clear(); // specialized routine for clearing trees
}
// Set/Get functions
int getSize() const {return vTrees.size();} // get size of trees
int getDepth() const {return vTrees[0]->getDepth();}
int getPatchWidth(){ return vTrees[0]->getPatchWidth(); }
int getPatchHeight(){ return vTrees[0]->getPatchHeight(); }
int getNoChans(){ return vTrees[0]->getNoChannels(); }
std::vector< const LeafNode* > regressionIntegral( const std::vector< cv::Mat >& patch, const cv::Mat& nonZeros, const cv::Rect& roi ) const;
bool loadForest(const char* filename);
// Trees
std::vector<CRTree*> vTrees;
};
// Regression
inline std::vector<const LeafNode*> CRForest::regressionIntegral( const std::vector< cv::Mat >& patch, const cv::Mat& nonZeros, const cv::Rect& roi ) const {
std::vector<const LeafNode*> res;
for(int i=0; i<(int)vTrees.size(); ++i)
res.push_back( vTrees[i]->regressionIntegral(patch,nonZeros,roi) );
return res;
}
inline bool CRForest::loadForest(const char* filename) {
char buffer[200];
bool success = true;
for(unsigned int i=0; i<vTrees.size(); ++i) {
sprintf(buffer,"%s%03d.bin",filename,i);
vTrees[i] = new CRTree();
success &= vTrees[i]->loadTree(buffer);
}
return success;
}
#endif