-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPUAdapter.h
100 lines (74 loc) · 2.19 KB
/
GPUAdapter.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef DEF_GPU_ADAPTER
#define DEF_GPU_ADAPTER
#include <vector>
#include <iostream>
#include "SemanticSegmentationForests.h"
#include "StrucClassSSF.h"
using namespace std;
using namespace vision;
typedef struct ANode{
//TNode
int id;
int parent;
int left;
int right;
uint32_t start, end;
uint16_t depth;
uint32_t idx;
//Prediction
/*uint32_t histSize;
uint32_t* hist;
float* p;*/
///histSize and hist storage
uint32_t histSize;
int common_hist_tab_offset;
int common_hist_tab_size;
// p
int common_p_tab_offset;
int common_p_tab_size;
//SplitData can be stored as it is
SplitData<float> splitData;
/*int16_t dx1, dx2;
int16_t dy1, dy2;
int8_t bw1, bh1, bw2, bh2;
uint8_t channel0; // number of feature channels is restricted by 255
uint8_t channel1;
uint8_t fType; // CW: split type
/*FeatureType*/ /*float thres; */
///
/*inline bool isLeaf()
{
return ((this->left == -1)/);
}*/
} ANode;
class GPUAdapter
{
public:
GPUAdapter(){}
~GPUAdapter();
void AddTree(StrucClassSSF<float>*tree);
void testGPUSolution(cv::Mat*, cv::Rect, Sample<float> &s);
void preKernel(uint16_t imageId, StrucClassSSF<float> *forest, ConfigReader *cr, TrainingSetSelection<float> *pTS);
ANode* PushTreeToGPU(int);
private:
vector<vector<ANode>* > treesAsVector;
ANode **treeAsTab;
unsigned int treeTabCount;
float *features;
float *features_integral;
vector<uint32_t> common_hist_tab;
vector<float> common_p_tab;
ImageData *pImageData;
uint16_t iWidth, iHeight, nChannels, numLabels;
uint16_t w_integral, h_integral;
TrainingSetSelection<float> *ts;
int lPXOff;
int lPYOff;
void getFlattenedFeatures(uint16_t imageId, float **out_features, uint16_t *out_nbChannels);
void getFlattenedIntegralFeatures(uint16_t imageId, float **out_features_integral, uint16_t *out_w, uint16_t *out_h);
/*Private use functions for all trees*/
void treeToVector(vector<ANode> *treeAsVector, StrucClassSSF<float>*tree);
//void treeToVectorRecursif(vector<ANode> *arbre, TNode<SplitData<float>, Prediction> *node, int parent,int id, int* id_counter);
int treeToVectorRecursif(vector<ANode> *arbre, TNode<SplitData<float>, Prediction> *node);
};
#endif