forked from luoyetx/JDA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.cpp
63 lines (56 loc) · 1.69 KB
/
test.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
#include <cstdio>
#include <opencv2/core/core.hpp>
#include "jda/data.hpp"
#include "jda/common.hpp"
#include "jda/cascador.hpp"
using namespace cv;
using namespace std;
using namespace jda;
/*!
* \breif Test JoinCascador Model over Test DataSet
*/
void test() {
const Config& c = Config::GetInstance();
JoinCascador joincascador;
JoinCascador faker;
FILE* fd = fopen("../model/jda.model", "rb");
JDA_Assert(fd, "Can not open `../model/jda.model`");
joincascador.SerializeFrom(fd);
fclose(fd);
DataSet pos, neg;
pos.LoadPositiveDataSet(c.test_pos_txt);
neg.LoadNegativeDataSet(c.test_neg_txt);
faker.current_stage_idx = -1;
faker.current_cart_idx = -1;
neg.MoreNegSamples(pos.size, 2.);
LOG("Test JoinCascador");
LOG("We have %d Positive Samples and %d Negative Samples", pos.size, neg.size);
int accept = 0;
for (int i = 0; i < pos.size; i++) {
bool is_face = joincascador.Validate(pos.imgs[i], pos.scores[i], pos.current_shapes[i]);
if (is_face) {
accept++;
}
}
double tp = static_cast<double>(accept) / static_cast<double>(pos.size) * 100.;
LOG("True Positive Rate = %.2lf%%", tp);
double e = calcMeanError(pos.gt_shapes, pos.current_shapes);
LOG("Shape Mean Error = %.4lf", e);
int reject = 0;
for (int i = 0; i < neg.size; i++) {
bool is_face = joincascador.Validate(neg.imgs[i], neg.scores[i], neg.current_shapes[i]);
if (!is_face) {
reject++;
}
}
double fp = (1 - static_cast<double>(reject) / static_cast<double>(neg.size)) * 100.;
LOG("False Positive Rate = %.2lf%%", fp);
LOG("Done");
}
/*!
* \breif Test JoinCascador Face Detection over FDDB
*/
void fddb() {
// **TODO** Run FDDB
dieWithMsg("Not completed Yet!");
}