forked from alessandroferrari/MuHi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPupilStack.cpp
97 lines (70 loc) · 1.39 KB
/
PupilStack.cpp
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
class CircleStack{
float **hold;
int size;
float candidate[3];
public:
CircleStack(int _size){
size = _size;
hold = new float*[size];
for (int h = 0; h < size; ++h)
hold[h] = new float[3];
//Init to all 0.0
int i,j;
for(i=0; i<size; i++){
for(j=0; j<3; j++){
hold[i][j]=0.0;
}
}
for(i=0; i<3; i++)
candidate[i]=0.0;
}
//private float *cvseqToFloat(CvSeq *input) { return 0.0; }
//Update 3 value that describe the possible center
// and radius of the most probable circle found
void update_candidate(){
float temp;
int i,j;
for(j=0; j<3; j++){
temp=0;
for(i=0; i<size; i++){
temp=temp+hold[i][j];
}
//Update the corrisponding candidate's value
candidate[j]=temp/size;
}
}
float *get_candidate(){
return candidate;
}
float *push(float *input){
int i=0;
for(i=0; i<size-1; i++){
hold[i]=hold[i+1];
}
hold[size-1]=input;
update_candidate();
return input;
}
void empty_stack(){
for(int i=0; i<size; i++)
pop(i);
}
void pop(int index){
if(index<=size && index>=0){
hold[index][0]=0.0;
hold[index][1]=0.0;
hold[index][2]=0.0;
}
}
float *get_element(int index){
if(index<=size && index>=0)
return hold[index];
return NULL;
}
float *set_element(float *input, int index){
if(index<=size && index>=0)
hold[index]=input;
else return NULL;
return input;
}
};