-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfddb.cpp
49 lines (44 loc) · 1.72 KB
/
fddb.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
#include "PCN.h"
int main()
{
std::string dataPath = "/home/jack/Desktop/fddb/originalPics/";
std::ofstream out("detList.txt");
std::ifstream in("/home/jack/Desktop/fddb/image_fold-total_noext.txt");
std::string line;
int total = 0;
float time = 0;
PCN detector("model/PCN.caffemodel",
"model/PCN-1.prototxt", "model/PCN-2.prototxt", "model/PCN-3.prototxt");
detector.SetMinFaceSize(20);
detector.SetScoreThresh(0.37, 0.43, 0.7);
detector.SetImagePyramidScaleFactor(1.414);
detector.SetVideoSmooth(false);
while (std::getline(in, line))
{
std::cout << line << std::endl;
cv::Mat img = cv::imread(dataPath + line + ".jpg");
long t0 = cv::getTickCount();
std::vector<Window> faces = detector.DetectFace(img);
long t1 = cv::getTickCount();
time += (t1 - t0) / cv::getTickFrequency();
total += 1;
std::cout << "count: " << total << " ave time: " <<
time / total << "s" << std::endl;
out << line << std::endl;
out << faces.size() << std::endl;
for (int i = 0; i < faces.size(); i++)
{
if (abs(faces[i].angle) < 45 or abs(faces[i].angle) > 135)
out << faces[i].x << " " << faces[i].y - 0.1 * faces[i].width << " " <<
faces[i].width << " " << faces[i].width * 1.2 << " " <<
faces[i].score << std::endl;
else
out << faces[i].x - 0.1 * faces[i].width << " " << faces[i].y << " " <<
faces[i].width * 1.2 << " " << faces[i].width << " " <<
faces[i].score << std::endl;
}
}
in.close();
out.close();
return 0;
}