16
16
namespace fastdeploy {
17
17
namespace vision {
18
18
19
- void ClassifyResult::Clear () {
19
+ void ClassifyResult::Free () {
20
20
std::vector<int32_t >().swap (label_ids);
21
21
std::vector<float >().swap (scores);
22
22
}
23
23
24
+ void ClassifyResult::Clear () {
25
+ label_ids.clear ();
26
+ scores.clear ();
27
+ }
28
+
24
29
std::string ClassifyResult::Str () {
25
30
std::string out;
26
31
out = " ClassifyResult(\n label_ids: " ;
@@ -47,11 +52,16 @@ void Mask::Reserve(int size) { data.reserve(size); }
47
52
48
53
void Mask::Resize (int size) { data.resize (size); }
49
54
50
- void Mask::Clear () {
55
+ void Mask::Free () {
51
56
std::vector<uint8_t >().swap (data);
52
57
std::vector<int64_t >().swap (shape);
53
58
}
54
59
60
+ void Mask::Clear () {
61
+ data.clear ();
62
+ shape.clear ();
63
+ }
64
+
55
65
std::string Mask::Str () {
56
66
std::string out = " Mask(" ;
57
67
size_t ndim = shape.size ();
@@ -94,26 +104,38 @@ DetectionResult& DetectionResult::operator=(DetectionResult&& other) {
94
104
return *this ;
95
105
}
96
106
97
- void DetectionResult::Clear () {
107
+ void DetectionResult::Free () {
98
108
std::vector<std::array<float , 4 >>().swap (boxes);
99
109
std::vector<float >().swap (scores);
100
110
std::vector<int32_t >().swap (label_ids);
101
111
std::vector<Mask>().swap (masks);
102
112
contain_masks = false ;
103
113
}
104
114
115
+ void DetectionResult::Clear () {
116
+ boxes.clear ();
117
+ scores.clear ();
118
+ label_ids.clear ();
119
+ masks.clear ();
120
+ contain_masks = false ;
121
+ }
122
+
105
123
void DetectionResult::Reserve (int size) {
106
124
boxes.reserve (size);
107
125
scores.reserve (size);
108
126
label_ids.reserve (size);
109
- masks.reserve (size);
127
+ if (contain_masks) {
128
+ masks.reserve (size);
129
+ }
110
130
}
111
131
112
132
void DetectionResult::Resize (int size) {
113
133
boxes.resize (size);
114
134
scores.resize (size);
115
135
label_ids.resize (size);
116
- masks.resize (size);
136
+ if (contain_masks) {
137
+ masks.resize (size);
138
+ }
117
139
}
118
140
119
141
std::string DetectionResult::Str () {
@@ -139,12 +161,18 @@ std::string DetectionResult::Str() {
139
161
return out;
140
162
}
141
163
142
- void KeyPointDetectionResult::Clear () {
164
+ void KeyPointDetectionResult::Free () {
143
165
std::vector<std::array<float , 2 >>().swap (keypoints);
144
166
std::vector<float >().swap (scores);
145
167
num_joints = -1 ;
146
168
}
147
169
170
+ void KeyPointDetectionResult::Clear () {
171
+ keypoints.clear ();
172
+ scores.clear ();
173
+ num_joints = -1 ;
174
+ }
175
+
148
176
void KeyPointDetectionResult::Reserve (int size) { keypoints.reserve (size); }
149
177
150
178
void KeyPointDetectionResult::Resize (int size) { keypoints.resize (size); }
@@ -155,8 +183,8 @@ std::string KeyPointDetectionResult::Str() {
155
183
out = " KeyPointDetectionResult: [x, y, conf]\n " ;
156
184
for (size_t i = 0 ; i < keypoints.size (); ++i) {
157
185
out = out + std::to_string (keypoints[i][0 ]) + " ," +
158
- std::to_string (keypoints[i][1 ]) + " , " +
159
- std::to_string (scores[i]) + " \n " ;
186
+ std::to_string (keypoints[i][1 ]) + " , " + std::to_string (scores[i]) +
187
+ " \n " ;
160
188
}
161
189
out += " num_joints:" + std::to_string (num_joints) + " \n " ;
162
190
return out;
@@ -170,22 +198,22 @@ void OCRResult::Clear() {
170
198
cls_labels.clear ();
171
199
}
172
200
173
- void MOTResult::Clear (){
201
+ void MOTResult::Clear () {
174
202
boxes.clear ();
175
203
ids.clear ();
176
204
scores.clear ();
177
205
class_ids.clear ();
178
206
}
179
207
180
- std::string MOTResult::Str (){
208
+ std::string MOTResult::Str () {
181
209
std::string out;
182
- out = " MOTResult:\n all boxes counts: " + std::to_string (boxes.size ())+ " \n " ;
210
+ out = " MOTResult:\n all boxes counts: " + std::to_string (boxes.size ()) + " \n " ;
183
211
out += " [xmin\t ymin\t xmax\t ymax\t id\t score]\n " ;
184
212
for (size_t i = 0 ; i < boxes.size (); ++i) {
185
- out = out + " [" + std::to_string (boxes[i][0 ]) + " \t " +
213
+ out = out + " [" + std::to_string (boxes[i][0 ]) + " \t " +
186
214
std::to_string (boxes[i][1 ]) + " \t " + std::to_string (boxes[i][2 ]) +
187
- " \t " + std::to_string (boxes[i][3 ]) + " \t " +
188
- std::to_string (ids[i]) + " \t " + std::to_string (scores[i]) + " ]\n " ;
215
+ " \t " + std::to_string (boxes[i][3 ]) + " \t " + std::to_string (ids[i]) +
216
+ " \t " + std::to_string (scores[i]) + " ]\n " ;
189
217
}
190
218
return out;
191
219
}
@@ -197,13 +225,20 @@ FaceDetectionResult::FaceDetectionResult(const FaceDetectionResult& res) {
197
225
landmarks_per_face = res.landmarks_per_face ;
198
226
}
199
227
200
- void FaceDetectionResult::Clear () {
228
+ void FaceDetectionResult::Free () {
201
229
std::vector<std::array<float , 4 >>().swap (boxes);
202
230
std::vector<float >().swap (scores);
203
231
std::vector<std::array<float , 2 >>().swap (landmarks);
204
232
landmarks_per_face = 0 ;
205
233
}
206
234
235
+ void FaceDetectionResult::Clear () {
236
+ boxes.clear ();
237
+ scores.clear ();
238
+ landmarks.clear ();
239
+ landmarks_per_face = 0 ;
240
+ }
241
+
207
242
void FaceDetectionResult::Reserve (int size) {
208
243
boxes.reserve (size);
209
244
scores.reserve (size);
@@ -257,23 +292,22 @@ std::string FaceDetectionResult::Str() {
257
292
return out;
258
293
}
259
294
260
- void FaceAlignmentResult::Clear () {
295
+ void FaceAlignmentResult::Free () {
261
296
std::vector<std::array<float , 2 >>().swap (landmarks);
262
297
}
263
298
264
- void FaceAlignmentResult::Reserve (int size) {
265
- landmarks.resize (size);
266
- }
299
+ void FaceAlignmentResult::Clear () { landmarks.clear (); }
267
300
268
- void FaceAlignmentResult::Resize (int size) {
269
- landmarks. resize (size);
270
- }
301
+ void FaceAlignmentResult::Reserve (int size) { landmarks. resize (size); }
302
+
303
+ void FaceAlignmentResult::Resize ( int size) { landmarks. resize (size); }
271
304
272
305
std::string FaceAlignmentResult::Str () {
273
306
std::string out;
274
307
275
308
out = " FaceAlignmentResult: [x, y]\n " ;
276
- out = out + " There are " +std::to_string (landmarks.size ()) + " landmarks, the top 10 are listed as below:\n " ;
309
+ out = out + " There are " + std::to_string (landmarks.size ()) +
310
+ " landmarks, the top 10 are listed as below:\n " ;
277
311
int landmarks_size = landmarks.size ();
278
312
size_t result_length = std::min (10 , landmarks_size);
279
313
for (size_t i = 0 ; i < result_length; ++i) {
@@ -355,7 +389,9 @@ FaceRecognitionResult::FaceRecognitionResult(const FaceRecognitionResult& res) {
355
389
embedding.assign (res.embedding .begin (), res.embedding .end ());
356
390
}
357
391
358
- void FaceRecognitionResult::Clear () { std::vector<float >().swap (embedding); }
392
+ void FaceRecognitionResult::Free () { std::vector<float >().swap (embedding); }
393
+
394
+ void FaceRecognitionResult::Clear () { embedding.clear (); }
359
395
360
396
void FaceRecognitionResult::Reserve (int size) { embedding.reserve (size); }
361
397
@@ -536,28 +572,23 @@ std::string OCRResult::Str() {
536
572
return no_result;
537
573
}
538
574
539
- void HeadPoseResult::Clear () {
540
- std::vector<float >().swap (euler_angles);
541
- }
575
+ void HeadPoseResult::Free () { std::vector<float >().swap (euler_angles); }
542
576
543
- void HeadPoseResult::Reserve (int size) {
544
- euler_angles.resize (size);
545
- }
577
+ void HeadPoseResult::Clear () { euler_angles.clear (); }
546
578
547
- void HeadPoseResult::Resize (int size) {
548
- euler_angles. resize (size);
549
- }
579
+ void HeadPoseResult::Reserve (int size) { euler_angles. resize (size); }
580
+
581
+ void HeadPoseResult::Resize ( int size) { euler_angles. resize (size); }
550
582
551
583
std::string HeadPoseResult::Str () {
552
584
std::string out;
553
585
554
586
out = " HeadPoseResult: [yaw, pitch, roll]\n " ;
555
- out = out + " yaw: " + std::to_string (euler_angles[0 ]) + " \n " +
556
- " pitch: " + std::to_string (euler_angles[1 ]) + " \n " +
557
- " roll: " + std::to_string (euler_angles[2 ]) + " \n " ;
587
+ out = out + " yaw: " + std::to_string (euler_angles[0 ]) + " \n " + " pitch: " +
588
+ std::to_string (euler_angles[1 ]) + " \n " + " roll: " +
589
+ std::to_string (euler_angles[2 ]) + " \n " ;
558
590
return out;
559
591
}
560
592
561
-
562
593
} // namespace vision
563
594
} // namespace fastdeploy
0 commit comments