You've already forked FrameTour-BE
feat(face): 添加人工调整标记字段并优化匹配逻辑
- 在 FaceEntity 中新增 isManual 字段,用于标识是否经过人工调整 - 优化人脸识别匹配流程,若已人工调整则跳过自动匹配 - 更新 FaceMapper.xml,支持 isManual 字段的更新操作 - 在处理自定义人脸匹配时,设置人工调整标记并清除缓存
This commit is contained in:
@@ -41,6 +41,10 @@ public class FaceEntity {
|
|||||||
* 匹配的结果,JSON字符串
|
* 匹配的结果,JSON字符串
|
||||||
*/
|
*/
|
||||||
private String matchResult;
|
private String matchResult;
|
||||||
|
/**
|
||||||
|
* 是否人工调整过,0-否,1-是
|
||||||
|
*/
|
||||||
|
private Integer isManual;
|
||||||
private Date createAt;
|
private Date createAt;
|
||||||
private Date updateAt;
|
private Date updateAt;
|
||||||
private int isDelete;
|
private int isDelete;
|
||||||
|
|||||||
@@ -290,19 +290,23 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
if (faceId == null) {
|
if (faceId == null) {
|
||||||
throw new IllegalArgumentException("faceId 不能为空");
|
throw new IllegalArgumentException("faceId 不能为空");
|
||||||
}
|
}
|
||||||
|
// 1. 数据准备:获取人脸信息、景区配置、适配器等
|
||||||
|
FaceEntity face = faceRepository.getFace(faceId);
|
||||||
|
if (face == null) {
|
||||||
|
log.warn("人脸不存在,faceId: {}", faceId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNew && Integer.valueOf(1).equals(face.getIsManual())) {
|
||||||
|
log.info("人工选择的,无需匹配,faceId: {}", faceId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
log.debug("开始人脸匹配:faceId={}, isNew={}", faceId, isNew);
|
log.debug("开始人脸匹配:faceId={}, isNew={}", faceId, isNew);
|
||||||
|
|
||||||
// 记录识别次数到Redis,设置2天过期时间
|
// 记录识别次数到Redis,设置2天过期时间
|
||||||
recordFaceRecognitionCount(faceId);
|
recordFaceRecognitionCount(faceId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. 数据准备:获取人脸信息、景区配置、适配器等
|
|
||||||
FaceEntity face = faceRepository.getFace(faceId);
|
|
||||||
if (face == null) {
|
|
||||||
log.warn("人脸不存在,faceId: {}", faceId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
|
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
|
||||||
IFaceBodyAdapter faceBodyAdapter = scenicService.getScenicFaceBodyAdapter(face.getScenicId());
|
IFaceBodyAdapter faceBodyAdapter = scenicService.getScenicFaceBodyAdapter(face.getScenicId());
|
||||||
@@ -1293,6 +1297,14 @@ public class FaceServiceImpl implements FaceService {
|
|||||||
if (finalSampleList.isEmpty()) {
|
if (finalSampleList.isEmpty()) {
|
||||||
throw new BaseException("至少需要保留一个样本");
|
throw new BaseException("至少需要保留一个样本");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置人工调整标记
|
||||||
|
FaceEntity updateEntity = new FaceEntity();
|
||||||
|
updateEntity.setId(faceId);
|
||||||
|
updateEntity.setIsManual(1);
|
||||||
|
faceMapper.update(updateEntity);
|
||||||
|
faceRepository.clearFaceCache(faceId);
|
||||||
|
|
||||||
handleCustomFaceMatching(faceId, finalSampleList);
|
handleCustomFaceMatching(faceId, finalSampleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
<if test="faceUrl!= null and faceUrl!= ''">
|
<if test="faceUrl!= null and faceUrl!= ''">
|
||||||
face_url = #{faceUrl},
|
face_url = #{faceUrl},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="isManual!= null ">
|
||||||
|
is_manual = #{isManual},
|
||||||
|
</if>
|
||||||
match_sample_ids = #{matchSampleIds},
|
match_sample_ids = #{matchSampleIds},
|
||||||
first_match_rate = #{firstMatchRate},
|
first_match_rate = #{firstMatchRate},
|
||||||
match_result = #{matchResult},
|
match_result = #{matchResult},
|
||||||
|
|||||||
Reference in New Issue
Block a user