You've already forked FrameTour-BE
feat(face): 添加人脸识别重试功能并优化得分筛选逻辑
- 在FaceSampleController中新增retryFaceRecognition接口用于手动重试失败的人脸识别任务- 集成人脸识别Kafka服务,支持异步处理重试请求- 在FaceServiceImpl中增加从景区配置读取人脸得分阈值的功能 - 根据配置的得分阈值对人脸识别结果进行筛选,过滤低分样本 - 添加详细的日志记录和异常处理机制- 优化线程池使用,确保重试任务能够正确提交和执行
This commit is contained in:
@@ -1341,12 +1341,32 @@ public class FaceServiceImpl implements FaceService {
|
||||
resultItems = Collections.emptyList();
|
||||
}
|
||||
|
||||
// 获取景区配置的得分阈值
|
||||
Float scoreThreshold = null;
|
||||
try {
|
||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
|
||||
if (scenicConfig != null) {
|
||||
BigDecimal thresholdConfig = scenicConfig.getBigDecimal("face_select_score_threshold");
|
||||
if (thresholdConfig != null) {
|
||||
// 配置值是0~100的小数,需要转换为0~1的阈值
|
||||
scoreThreshold = thresholdConfig.floatValue() / 100.0f;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取景区人脸得分阈值配置失败, scenicId: {}, 将不进行得分筛选", face.getScenicId(), e);
|
||||
}
|
||||
|
||||
List<Long> persistedAcceptedIds = parseMatchSampleIds(face.getMatchSampleIds());
|
||||
LinkedHashSet<Long> sampleUniverse = new LinkedHashSet<>();
|
||||
Map<Long, SearchFaceResultItem> itemBySampleId = new LinkedHashMap<>();
|
||||
for (SearchFaceResultItem item : resultItems) {
|
||||
Long sampleId = parseLongSilently(item.getExtData());
|
||||
if (sampleId != null) {
|
||||
// 根据得分阈值筛选样本
|
||||
if (scoreThreshold != null && item.getScore() != null && item.getScore() < scoreThreshold) {
|
||||
// 得分低于阈值,跳过此样本
|
||||
continue;
|
||||
}
|
||||
sampleUniverse.add(sampleId);
|
||||
itemBySampleId.putIfAbsent(sampleId, item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user