Commit ce7fe5c5 by xmh

修复人体匹配

1 parent 6cf8d7d7
......@@ -32,6 +32,7 @@ public class ResponseVo {
private Integer match;
private List<PoolInfo> poolIds;
private List<Person> matchPersons;
private List<Person> matchBodies;
public ResponseVo(String rid) {
this.rid = rid;
......
......@@ -35,6 +35,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* .
......@@ -61,7 +62,8 @@ public class PersonService {
String poolId = requestVo.getPersonPoolId();
List<String> unionPersonPoolId = requestVo.getUnionPersonPoolId();
List<String> poolIds = new ArrayList<>();
List<Person> result = new ArrayList<>();
List<Person> matchFaces = new ArrayList<>();
List<Person> matchBodies = new ArrayList<>();
List<Pool> poolStatus = new ArrayList<>();
if (unionPersonPoolId != null && unionPersonPoolId.size() > 0) {
......@@ -77,16 +79,21 @@ public class PersonService {
pool.setPersonPoolId(id);
if (poolService.existPool(id)) {
pool.setStatus(0);
List<Person> people = matchPerson(id, requestVo.getPerson());
result.addAll(people);
List<Person> face = matchPerson(id, requestVo.getPerson(),0);
matchFaces.addAll(face);
List<Person> body = matchPerson(id, requestVo.getPerson(), 1);
matchBodies.addAll(body);
} else {
pool.setStatus(1);
}
poolStatus.add(pool);
}
ResponseVo success = ResponseVo.success(rid, "success");
if (result.size() > 0) {
success.setMatchPersons(result);
if (matchFaces.size() > 0) {
success.setMatchPersons(matchFaces);
}
if (matchBodies.size() > 0) {
success.setMatchBodies(matchBodies);
}
success.setMatch(1);
success.setPersonPoolStatus(poolStatus);
......@@ -194,18 +201,22 @@ public class PersonService {
}
public List<Person> matchPerson(String poolId, Person person) throws Exception {
public List<Person> matchPerson(String poolId, Person person , int type) throws Exception {
List<Person> matchResult = new ArrayList<>();
List<FaceFeature> faceFeatures = person.getFaceFeatures();
matchFace(faceFeatures, poolId, matchResult);
List<BodyFeature> bodyFeatures = person.getBodyFeatures();
matchBody(bodyFeatures, poolId, matchResult);
if (type == 0) {
List<FaceFeature> faceFeatures = person.getFaceFeatures();
matchFace(faceFeatures, poolId, matchResult);
}else {
List<BodyFeature> bodyFeatures = person.getBodyFeatures();
matchBody(bodyFeatures, poolId, matchResult);
}
Stream<Person> stream = matchResult.stream().sorted(Comparator.comparingInt(Person::getScore));
if (matchResult.size() > Constant.MATCH_RESULT_SIZE) {
matchResult = matchResult.stream().sorted(Comparator.comparingInt(Person::getScore)).limit(5).collect(Collectors.toList());
stream = stream.limit(5);
}
matchResult = stream.collect(Collectors.toList());
return matchResult;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!