11 #include <opencv/cv.h> 18 this->weights = vector<double>(2);
19 this->weights[0] = r1weight;
20 this->weights[1] = r2weight;
21 this->regions = vector<int>(8);
22 this->regions[0] = r1x1;
23 this->regions[1] = r1x2;
24 this->regions[2] = r1y1;
25 this->regions[3] = r1y2;
26 this->regions[4] = r2x1;
27 this->regions[5] = r2x2;
28 this->regions[6] = r2y1;
29 this->regions[7] = r2y2;
33 CHaarFeature::CHaarFeature(
int r1x1,
int r1x2,
int r1y1,
int r1y2,
int r2x1,
int r2x2,
int r2y1,
int r2y2,
int r3x1,
int r3x2,
int r3y1,
int r3y2,
double r1weight,
double r2weight,
double r3weight){
35 this->weights = vector<double>(3);
36 this->weights[0] = r1weight;
37 this->weights[1] = r2weight;
38 this->weights[2] = r3weight;
39 this->regions = vector<int>(12);
40 this->regions[0] = r1x1;
41 this->regions[1] = r1x2;
42 this->regions[2] = r1y1;
43 this->regions[3] = r1y2;
44 this->regions[4] = r2x1;
45 this->regions[5] = r2x2;
46 this->regions[6] = r2y1;
47 this->regions[7] = r2y2;
48 this->regions[8] = r3x1;
49 this->regions[9] = r3x2;
50 this->regions[10] = r3y1;
51 this->regions[11] = r3y2;
54 CHaarFeature::CHaarFeature(
int r1x1,
int r1x2,
int r1y1,
int r1y2,
int r2x1,
int r2x2,
int r2y1,
int r2y2,
int r3x1,
int r3x2,
int r3y1,
int r3y2,
int r4x1,
int r4x2,
int r4y1,
int r4y2, \
55 double r1weight,
double r2weight,
double r3weight,
double r4weight){
57 this->weights = vector<double>(4);
58 this->weights[0] = r1weight;
59 this->weights[1] = r2weight;
60 this->weights[2] = r3weight;
61 this->regions = vector<int>(16);
62 this->regions[0] = r1x1;
63 this->regions[1] = r1x2;
64 this->regions[2] = r1y1;
65 this->regions[3] = r1y2;
66 this->regions[4] = r2x1;
67 this->regions[5] = r2x2;
68 this->regions[6] = r2y1;
69 this->regions[7] = r2y2;
70 this->regions[8] = r3x1;
71 this->regions[9] = r3x2;
72 this->regions[10] = r3y1;
73 this->regions[11] = r3y2;
74 this->regions[12] = r4x1;
75 this->regions[13] = r4x2;
76 this->regions[14] = r4y1;
77 this->regions[15] = r4y2;
85 double retval_old = 0;
86 for (
int reg = 0; reg < this->nr_reg; reg++){
87 double weight = this->weights[reg];
88 int colx1 = pos_x + this->regions[4*reg];
89 int colx2 = pos_x + this->regions[4*reg+1];
90 int rowy1 = pos_y + this->regions[4*reg+2];
91 int rowy2 = pos_y + this->regions[4*reg+3];
93 retval = retval + weight*(
94 ((
double*)(heightsIntegral.ptr() + heightsIntegral.step*(rowy2)))[colx2]
95 + ((
double*)(heightsIntegral.ptr() + heightsIntegral.step*(rowy1-1)))[colx1-1]
96 - ((
double*)(heightsIntegral.ptr() + heightsIntegral.step*(rowy2)))[colx1-1]
97 - ((
double*)(heightsIntegral.ptr() + heightsIntegral.step*(rowy1-1)))[colx2]
CHaarFeature(int r1x1, int r1x2, int r1y1, int r1y2, int r2x1, int r2x2, int r2y1, int r2y2, double r1weight, double r2weight)
double calcFval(cv::Mat heightsIntegral, int pos_x, int pos_y)