Commit fa91890d by 朱海

[chg]人员库支持不同的比对分数

1 parent b7916465
...@@ -22,8 +22,9 @@ public class PersonInfo { ...@@ -22,8 +22,9 @@ public class PersonInfo {
private String channelSerialNum; private String channelSerialNum;
private Long gateId; private Long gateId;
private String direction; private String direction;
private Long personType;
public PersonInfo(String unid, String personId, Double[] body,Double[] data, Integer age, String gender, Integer bodyType, Date countTime, String fid, String channelSerialNum, Long gateId, String direction) { public PersonInfo(String unid, String personId, Double[] body,Double[] data, Integer age, String gender, Integer bodyType, Date countTime, String fid, String channelSerialNum, Long gateId, String direction, Long personType) {
this.unid = unid; this.unid = unid;
this.personId = personId; this.personId = personId;
this.body = body; this.body = body;
...@@ -37,5 +38,6 @@ public class PersonInfo { ...@@ -37,5 +38,6 @@ public class PersonInfo {
this.gateId = gateId; this.gateId = gateId;
this.direction = direction; this.direction = direction;
this._score = "1"; this._score = "1";
this.personType = personType;
} }
} }
...@@ -23,4 +23,5 @@ public class SearchResultHit { ...@@ -23,4 +23,5 @@ public class SearchResultHit {
private String channelSerialNum; private String channelSerialNum;
private Long gateId; private Long gateId;
private String direction; private String direction;
private Long personType;
} }
...@@ -49,7 +49,7 @@ import java.util.stream.Stream; ...@@ -49,7 +49,7 @@ import java.util.stream.Stream;
@Service @Service
@Slf4j @Slf4j
public class PersonService { public class PersonService {
private static final String[] FETCH_SOURCE = new String[]{"personId", "age", "gender", "fid", "counttime", "channelSerialNum", "body_type","unid"}; private static final String[] FETCH_SOURCE = new String[]{"personId", "age", "gender", "fid", "counttime", "channelSerialNum", "body_type","unid","personType"};
@Resource @Resource
private ElasticsearchClient client; private ElasticsearchClient client;
...@@ -257,6 +257,7 @@ public class PersonService { ...@@ -257,6 +257,7 @@ public class PersonService {
String direction = person.getDirection(); String direction = person.getDirection();
//Long gateId = person.getGateId(); //Long gateId = person.getGateId();
Integer bodyType = person.getBodyType(); Integer bodyType = person.getBodyType();
Long personType = person.getPersonType();
String personChannelSerialNum = person.getChannelSerialNum(); String personChannelSerialNum = person.getChannelSerialNum();
List<FaceFeature> faceFeatures = person.getFaceFeatures(); List<FaceFeature> faceFeatures = person.getFaceFeatures();
if (CollectionUtils.isNotEmpty(faceFeatures)) { if (CollectionUtils.isNotEmpty(faceFeatures)) {
...@@ -273,7 +274,7 @@ public class PersonService { ...@@ -273,7 +274,7 @@ public class PersonService {
// "counttime", personCountTime == null ? null : Constant.DATE_FORMAT.get().format(personCountTime), // "counttime", personCountTime == null ? null : Constant.DATE_FORMAT.get().format(personCountTime),
// "channelSerialNum", personChannelSerialNum, "gateId", gateId, "direction", direction); // "channelSerialNum", personChannelSerialNum, "gateId", gateId, "direction", direction);
// bulkRequest.add(indexRequest); // bulkRequest.add(indexRequest);
operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction)).build()).build()); operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction, personType)).build()).build());
} }
} }
} }
...@@ -303,7 +304,7 @@ public class PersonService { ...@@ -303,7 +304,7 @@ public class PersonService {
// "counttime", counttime == null ? null : Constant.DATE_FORMAT.get().format(counttime) // "counttime", counttime == null ? null : Constant.DATE_FORMAT.get().format(counttime)
// , "channelSerialNum", channelSerialNum, "gateId", gateId, "direction", direction); // , "channelSerialNum", channelSerialNum, "gateId", gateId, "direction", direction);
// bulkRequest.add(indexRequest); // bulkRequest.add(indexRequest);
operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction)).build()).build()); operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction, personType)).build()).build());
} }
} }
} }
...@@ -537,11 +538,19 @@ public class PersonService { ...@@ -537,11 +538,19 @@ public class PersonService {
} else { } else {
// builder.size(matchResultSize); // builder.size(matchResultSize);
} }
Float matchScore = null;
Map<String, Float> poolMatchScoreMap = person.getPoolMatchScoreMap();
if (poolMatchScoreMap != null) {
matchScore = poolMatchScoreMap.get(poolId);
}
if (matchScore == null) {
matchScore = person.getBodyMinScore();
}
SourceConfig sourceConfig = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build(); SourceConfig sourceConfig = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build();
// log.debug("rid:{} poolId:{} 匹配时参数:{}", rid, poolId, scriptScoreQuery.toString()); // log.debug("rid:{} poolId:{} 匹配时参数:{}", rid, poolId, scriptScoreQuery.toString());
// KnnSearch knnQuery = getKnnSearch(feature, person, type); // KnnSearch knnQuery = getKnnSearch(feature, person, type);
// ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, type); // ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, type);
return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(sourceConfig).size(matchResultSize).minScore(person.getBodyMinScore().doubleValue()/100).build(); return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(sourceConfig).size(matchResultSize).minScore(matchScore.doubleValue()/100).build();
} }
private List<Person> match0(SearchRequest searchRequest, Boolean agg) throws Exception { private List<Person> match0(SearchRequest searchRequest, Boolean agg) throws Exception {
...@@ -574,7 +583,7 @@ public class PersonService { ...@@ -574,7 +583,7 @@ public class PersonService {
p.setChannelSerialNum(hit.getChannelSerialNum()); p.setChannelSerialNum(hit.getChannelSerialNum());
p.setBodyType(hit.getBodyType()); p.setBodyType(hit.getBodyType());
p.setCaptureUnid(hit.getUnid()); p.setCaptureUnid(hit.getUnid());
p.setPersonType(hit.getPersonType());
p.setCounttime(Optional.ofNullable((String)hit.getCounttime()) p.setCounttime(Optional.ofNullable((String)hit.getCounttime())
.map(x -> { .map(x -> {
try { try {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!