feat(face): 添加低阈值检测功能

- 在 FaceConstant 中添加 FACE_LOW_THRESHOLD_PFX 常量
- 在 SearchFaceRespVo 中添加 lowThreshold 字段
- 在 FaceServiceImpl 中实现记录低阈值检测人脸的逻辑
- 在 TaskFaceServiceImpl 中添加低阈值检测的判断和结果设置
This commit is contained in:
2025-09-13 15:04:06 +08:00
parent 91e68c3272
commit bf672a8af7
4 changed files with 44 additions and 0 deletions

View File

@@ -171,6 +171,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
request.setLimit(200);
FaceDetectLog logEntity = FaceDetectLog.quickCreate(reason, request);
float threshold = 0;
float lowThreshold = 100;
ScenicConfigManager scenicConfig = null;
if (StringUtils.isNumeric(dbName)) {
scenicConfig = scenicRepository.getScenicConfigManager(Long.valueOf(dbName));
@@ -178,6 +179,9 @@ public class TaskFaceServiceImpl implements TaskFaceService {
if (scenicConfig.getFloat("face_score_threshold") != null) {
threshold = scenicConfig.getFloat("face_score_threshold") / 100F;
}
if (scenicConfig.getFloat("face_score_low_threshold") != null) {
lowThreshold = scenicConfig.getFloat("face_score_low_threshold") / 100F;
}
}
} else if (StringUtils.isNumeric(dbName.replace(USER_FACE_DB_NAME, ""))) {
Long scenicId = Long.valueOf(dbName.replace(USER_FACE_DB_NAME, ""));
@@ -186,6 +190,9 @@ public class TaskFaceServiceImpl implements TaskFaceService {
if (scenicConfig.getFloat("face_score_threshold") != null) {
threshold = scenicConfig.getFloat("face_score_threshold") / 100F;
}
if (scenicConfig.getFloat("face_score_low_threshold") != null) {
lowThreshold = scenicConfig.getFloat("face_score_low_threshold") / 100F;
}
}
}
final float _threshold = threshold;
@@ -212,6 +219,10 @@ public class TaskFaceServiceImpl implements TaskFaceService {
.filter(StringUtils::isNumeric)
.map(Long::valueOf)
.collect(Collectors.toList());
float _lowThreshold = lowThreshold;
boolean isLowThreshold = records.stream()
.anyMatch(record -> record.getScore() > _lowThreshold);
respVo.setLowThreshold(isLowThreshold);
allFaceSampleIds = records.stream()
.map(SearchFaceResultItem::getExtData)
.filter(StringUtils::isNumeric)