1
This commit is contained in:
parent
80e93ecd39
commit
4b03bfb871
@ -202,7 +202,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
request.setImageUrl(faceUrl);
|
||||
request.setLimit(200);
|
||||
// request.setQualityScoreThreshold(60f);
|
||||
FaceDetectLog log = FaceDetectLog.quickCreate(reason, request);
|
||||
FaceDetectLog logEntity = FaceDetectLog.quickCreate(reason, request);
|
||||
try {
|
||||
searchFaceLimiter.acquire();
|
||||
} catch (InterruptedException ignored) {
|
||||
@ -221,10 +221,10 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
}
|
||||
}
|
||||
final float _threshold = threshold;
|
||||
List<Long> faceSampleIds;
|
||||
List<Long> acceptFaceSampleIds;
|
||||
try {
|
||||
SearchFaceResponse response = client.getAcsResponse(request);
|
||||
log.fillResponse(response);
|
||||
logEntity.fillResponse(response);
|
||||
List<SearchFaceResponse.Data.MatchListItem> matchList = response.getData().getMatchList();
|
||||
if (matchList.isEmpty()) {
|
||||
return null;
|
||||
@ -236,27 +236,32 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
return respVo;
|
||||
}
|
||||
List<SearchFaceResponse.Data.MatchListItem.FaceItemsItem> records = matchList.get(0).getFaceItems();
|
||||
log.setMatchRawRecord(records);
|
||||
faceSampleIds = records.stream()
|
||||
logEntity.setMatchRawRecord(records);
|
||||
acceptFaceSampleIds = records.stream()
|
||||
.filter(record -> record.getScore() > _threshold)
|
||||
.map(SearchFaceResponse.Data.MatchListItem.FaceItemsItem::getExtraData)
|
||||
.filter(StringUtils::isNumeric)
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
List<FaceSampleEntity> faceSampleList = new ArrayList<>();
|
||||
if (StringUtils.isNumeric(dbName)) {
|
||||
faceSampleList = faceSampleMapper.listByIds(faceSampleIds);
|
||||
Long firstFaceSampleId = faceSampleIds.get(0);
|
||||
if (StringUtils.isNumeric(dbName)) { // 景区
|
||||
faceSampleList = faceSampleMapper.listByIds(acceptFaceSampleIds);
|
||||
Long firstFaceSampleId = acceptFaceSampleIds.get(0);
|
||||
Optional<FaceSampleEntity> firstFaceSample = faceSampleList.stream().filter(faceSample -> faceSample.getId().equals(firstFaceSampleId)).findAny();
|
||||
if (firstFaceSample.isPresent()) {
|
||||
if (tourMinutes > 0) {
|
||||
Date startDate = DateUtil.offsetMinute(firstFaceSample.get().getCreateAt(), -tourMinutes/2);
|
||||
Date endDate = DateUtil.offsetMinute(firstFaceSample.get().getCreateAt(), tourMinutes/2);
|
||||
faceSampleIds = faceSampleList.stream()
|
||||
acceptFaceSampleIds = faceSampleList.stream()
|
||||
.filter(faceSample -> faceSample.getCreateAt().after(startDate) && faceSample.getCreateAt().before(endDate))
|
||||
.map(FaceSampleEntity::getId)
|
||||
.collect(Collectors.toList());
|
||||
log.info("时间范围逻辑:最高匹配:{},时间范围需要在:{}~{}间", firstFaceSample, startDate, endDate);
|
||||
} else {
|
||||
log.info("时间范围逻辑:景区未限制");
|
||||
}
|
||||
} else {
|
||||
log.info("时间范围逻辑:最高匹配ID:{},未找到", firstFaceSampleId);
|
||||
}
|
||||
}
|
||||
List<MatchLocalRecord> collect = new ArrayList<>();
|
||||
@ -271,7 +276,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
if (device != null) {
|
||||
record.setDeviceName(device.getName());
|
||||
}
|
||||
record.setAccept(faceSampleIds.contains(optionalFse.get().getId()));
|
||||
record.setAccept(acceptFaceSampleIds.contains(optionalFse.get().getId()));
|
||||
record.setFaceUrl(optionalFse.get().getFaceUrl());
|
||||
record.setShotDate(optionalFse.get().getCreateAt());
|
||||
}
|
||||
@ -283,15 +288,15 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
record.setConfidence(item.getConfidence());
|
||||
collect.add(record);
|
||||
}
|
||||
log.setMatchLocalRecord(JSONObject.toJSONString(collect));
|
||||
logEntity.setMatchLocalRecord(JSONObject.toJSONString(collect));
|
||||
respVo.setFirstMatchRate(matchList.get(0).getFaceItems().get(0).getScore());
|
||||
respVo.setSampleListIds(faceSampleIds);
|
||||
respVo.setSampleListIds(acceptFaceSampleIds);
|
||||
return respVo;
|
||||
} catch (Exception e) {
|
||||
log.setMatchRawResult("识别错误,错误为:["+e.getLocalizedMessage()+"]");
|
||||
logEntity.setMatchRawResult("识别错误,错误为:["+e.getLocalizedMessage()+"]");
|
||||
throw new BaseException(e.getMessage());
|
||||
} finally {
|
||||
logMapper.insert(log);
|
||||
logMapper.insert(logEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user