Skip to content

Commit 88b5f41

Browse files
committed
add landmarks_score to filter capture faces
Change-Id: I8cd59f57e9ff26cfc9057a8853ddb14d15fff33f Reviewed-on: https://gerrit-ai.sophgo.vip:8443/148856 Reviewed-by: 振兴 叶 <zhenxing.ye@sophgo.com>
1 parent bfb6cbc commit 88b5f41

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/app/face_capture/face_capture_app.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,19 +366,11 @@ std::shared_ptr<PipelineNode> FaceCaptureApp::getLandmarkDetectionNode(
366366
float vel = std::hypot(t.velocity_x_, t.velocity_y_);
367367
std::map<std::string, float> other_info = {{"vel", vel}};
368368

369-
printf(
370-
"[0]face_info size: %d, t.obj_idx_: %d, "
371-
"box_landmark.landmarks_x.size(): %d\n",
372-
face_infos.size(), t.obj_idx_,
373-
face_infos[t.obj_idx_].landmarks_x.size());
374369
float face_quality = ObjectQualityHelper::getFaceQuality(
375370
face_infos[t.obj_idx_], image->getWidth(), image->getHeight(),
376371
other_info);
377372
face_qaulity_scores[t.obj_idx_] = face_quality;
378373

379-
printf("!! track id: %ld, face_qaulity_scores: %f\n", t.track_id_,
380-
face_quality);
381-
382374
if (face_quality > 0.4) {
383375
ObjectBoxLandmarkInfo face_info = rescale_face_infos[t.obj_idx_];
384376
// 1. 计算原始框的宽高和中心
@@ -447,6 +439,8 @@ std::shared_ptr<PipelineNode> FaceCaptureApp::getLandmarkDetectionNode(
447439
landmark_meta->landmarks_x;
448440
rescale_face_infos[t.obj_idx_].landmarks_y =
449441
landmark_meta->landmarks_y;
442+
rescale_face_infos[t.obj_idx_].landmarks_score =
443+
landmark_meta->landmarks_score;
450444

451445
face_infos[t.obj_idx_].landmarks_x.clear();
452446
face_infos[t.obj_idx_].landmarks_y.clear();
@@ -458,16 +452,23 @@ std::shared_ptr<PipelineNode> FaceCaptureApp::getLandmarkDetectionNode(
458452
face_infos[t.obj_idx_].landmarks_y.push_back(
459453
landmark_meta->landmarks_y[i] / scale + crop_y);
460454
}
455+
face_infos[t.obj_idx_].landmarks_score =
456+
landmark_meta->landmarks_score;
461457

462458
t.blurness =
463459
landmark_meta->attributes
464460
[TDLObjectAttributeType::OBJECT_CLS_ATTRIBUTE_FACE_BLURNESS];
465461
std::map<std::string, float> other_info = {{"vel", vel},
466462
{"blr", t.blurness}};
467-
468-
float face_quality = ObjectQualityHelper::getFaceQuality(
469-
face_infos[t.obj_idx_], image->getWidth(), image->getHeight(),
470-
other_info);
463+
float face_quality;
464+
465+
if (face_infos[t.obj_idx_].landmarks_score[0] < 0.4) {
466+
face_quality = -1.0f; // skip directly
467+
} else {
468+
face_quality = ObjectQualityHelper::getFaceQuality(
469+
face_infos[t.obj_idx_], image->getWidth(), image->getHeight(),
470+
other_info);
471+
}
471472

472473
LOGI("track_id:%lu,frame_id:%lu,face_quality:%f\n", t.track_id_,
473474
frame_info->frame_id_, face_quality);

src/app/face_pet_capture/face_pet_capture_app.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,17 @@ std::shared_ptr<PipelineNode> FacePetCaptureApp::getLandmarkDetectionNode(
466466
landmark_meta->landmarks_x;
467467
rescale_face_infos[t.obj_idx_].landmarks_y =
468468
landmark_meta->landmarks_y;
469+
rescale_face_infos[t.obj_idx_].landmarks_score =
470+
landmark_meta->landmarks_score;
469471

470-
for (int i = 0; i < landmark_meta->landmarks_x.size();
471-
i++) { // for eval
472+
for (int i = 0; i < landmark_meta->landmarks_x.size(); i++) {
472473
face_infos[t.obj_idx_].landmarks_x.push_back(
473474
landmark_meta->landmarks_x[i] / scale + crop_x);
474475
face_infos[t.obj_idx_].landmarks_y.push_back(
475476
landmark_meta->landmarks_y[i] / scale + crop_y);
476477
}
478+
face_infos[t.obj_idx_].landmarks_score =
479+
landmark_meta->landmarks_score;
477480
}
478481
}
479482
}
@@ -547,7 +550,8 @@ std::shared_ptr<PipelineNode> FacePetCaptureApp::getSnapshotNode(
547550
face_info.y1, face_info.x2, face_info.y2);
548551
float vel = std::hypot(t.velocity_x_, t.velocity_y_);
549552

550-
if (face_head_quality[t.obj_idx_] < 0.4) {
553+
if (face_head_quality[t.obj_idx_] < 0.4 ||
554+
face_infos[t.obj_idx_].landmarks_score[0] < 0.4) {
551555
face_qaulity_scores[t.track_id_] = -1.0f; // skip directly
552556
} else {
553557
std::map<std::string, float> other_info = {{"vel", vel},

0 commit comments

Comments
 (0)