-
Notifications
You must be signed in to change notification settings - Fork 180
/
nnie_face_test.cpp
165 lines (138 loc) · 4.08 KB
/
nnie_face_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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "nnie_face_api.h"
void NNIE_FACE_DET_TEST(void)
{
printf("Face Detector Start!!!");
char *pcModelName = "./data/nnie_model/face/mnet_640_inst.wk";
char *pcSrcFile1 = "./data/nnie_image/rgb_planar/det41.bgr";
char *pcSrcFile2 = "./data/nnie_image/rgb_planar/det39.bgr";
float threshold = 0.7;
int isLog = 1;
NNIE_FACE_DETECTOR_INIT(pcModelName, threshold, isLog);
for(int i = 0; i < 2; ++i)
{
printf("\n\n ========== =========== ========== ==========\n\n");
if(i%2)
NNIE_FACE_DETECTOR_GET(pcSrcFile1);
else
NNIE_FACE_DETECTOR_GET(pcSrcFile2);
}
NNIE_FACE_DETECTOR_RELEASE();
}
void NNIE_FACE_EXT_TEST(void)
{
printf("Face Extractor Start!!!");
char *pcModelName = "./data/nnie_model/face/mobilefacenet_inst.wk";
char *pcSrcFile1 = "./data/nnie_image/rgb_planar/id10.bgr";
char *pcSrcFile2 = "./data/nnie_image/rgb_planar/id11.bgr";
float threshold = 0.7;
int isLog = 0;
NNIE_FACE_EXTRACTOR_INIT(pcModelName);
float features[512] = {0};
for(int i = 0; i < 2; ++i)
{
printf("\n\n ========== =========== ========== ==========\n\n");
if(i%2)
NNIE_FACE_NNIE_EXTRACTOR_GET(pcSrcFile1, features);
else
NNIE_FACE_NNIE_EXTRACTOR_GET(pcSrcFile2, features);
printf("blobs fc1:\n[");
for(int f = 0; f < 512; ++f)
{
printf("%f ,",features[f]);
features[f] = 0;
}
printf("]\n");
}
NNIE_FACE_EXTRACTOR_RELEASE();
}
void NNIE_FACE_POSE_TEST(void)
{
printf("Face Pose Start!!!");
char *pcModelName = "./data/nnie_model/face/landmark_inst.wk";
char *pcSrcFile1 = "./data/nnie_image/rgb_planar/id10.bgr";
char *pcSrcFile2 = "./data/nnie_image/rgb_planar/pose.bgr";
NNIE_FACE_PFPLD_INIT(pcModelName);
float landmarks[196] = {0};
float angles[3] = {0};
for(int i = 0; i < 2; ++i)
{
printf("\n\n ========== =========== ========== ==========\n\n");
if(i%2)
NNIE_FACE_PFPLD_GET(pcSrcFile1, landmarks, angles);
else
NNIE_FACE_PFPLD_GET(pcSrcFile2, landmarks, angles);
printf("blobs 1:\n[");
for(int f = 0; f < 98; ++f)
{
printf("Pts:%d x:%f y:%f, ", f, landmarks[2*f] * 112, landmarks[2*f+1] * 112);
landmarks[2*f] = landmarks[2*f+1] = 0;
}
printf("]\n");
printf("blobs 2:\n[");
printf("Angles: yaw:%f pitch:%f roll:%f", angles[0], angles[1], angles[2]);
printf("]\n");
}
NNIE_FACE_PFPLD_RELEASE();
}
static char **s_ppChCmdArgv = NULL;
/******************************************************************************
* function : show usage
******************************************************************************/
void SAMPLE_SVP_Usage(char* pchPrgName)
{
printf("Usage : %s <index> \n", pchPrgName);
printf("index:\n");
printf("\t 4) Cnn(Read File).\n");
}
/******************************************************************************
* function : nnie sample
******************************************************************************/
int main(int argc, char *argv[])
{
int s32Ret = 1;
if (argc < 2 || argc > 2)
{
SAMPLE_SVP_Usage(argv[0]);
return 0;
}
if (!strncmp(argv[1], "-h", 2))
{
SAMPLE_SVP_Usage(argv[0]);
return 1;
}
s_ppChCmdArgv = argv;
switch (*argv[1])
{
case '0':
{
NNIE_FACE_DET_TEST();
}
break;
case '1':
{
NNIE_FACE_EXT_TEST();
}
break;
case '2':
{
NNIE_FACE_POSE_TEST();
}
break;
default :
{
SAMPLE_SVP_Usage(argv[0]);
}
break;
}
return s32Ret;
}