Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
VVAS-Match
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ef0950e4
authored
Oct 24, 2024
by
姚冰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg] 人脸存储,比对修正
1 parent
6f5de97a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
src/main/java/com/viontech/match/service/PersonService.java
src/main/java/com/viontech/match/service/PersonService.java
View file @
ef0950e
...
...
@@ -217,10 +217,13 @@ public class PersonService {
}
}
log
.
error
(
"matchPerson
"
,
e
);
log
.
error
(
"matchPerson
param1:{}"
,
JSON
.
toJSONString
(
requestVo
)
,
e
);
ResponseVo
error
=
ResponseVo
.
error
(
rid
,
e
.
getMessage
());
error
.
setMatch
(
0
);
return
error
;
}
catch
(
Exception
e
)
{
log
.
error
(
"matchPerson param:{}"
,
JSON
.
toJSONString
(
requestVo
),
e
);
throw
e
;
}
}
...
...
@@ -303,7 +306,7 @@ public class PersonService {
String
fid
=
faceFeature
.
getFid
();
String
unid
=
faceFeature
.
getUnid
();
Long
gateId
=
faceFeature
.
getGateId
();
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
,
mallId
)).
build
()).
build
());
operationList
.
add
(
new
BulkOperation
.
Builder
().
index
(
new
IndexOperation
.
Builder
<
PersonInfo
>().
index
(
poolId
).
document
(
new
PersonInfo
(
unid
,
personId
,
null
,
feature
,
age
,
gender
,
bodyType
,
personCountTime
,
fid
,
personChannelSerialNum
,
gateId
,
direction
,
mallId
)).
build
()).
build
());
}
}
}
...
...
@@ -521,15 +524,16 @@ public class PersonService {
KnnQuery
.
Builder
knnQuery
=
new
KnnQuery
.
Builder
();
if
(
null
!=
feature
&&
type
==
0
)
{
knnQuery
.
field
(
"data"
).
queryVector
(
getFeature
(
feature
)).
numCandidates
(
Constant
.
FACE_MATCH_RESULT_SIZE
);
queries
.
add
(
new
Query
.
Builder
().
exists
(
s
->
s
.
field
(
"data"
).
boost
(
1.0f
)).
build
());
}
else
if
(
null
!=
feature
&&
type
==
1
){
knnQuery
.
field
(
"body"
).
queryVector
(
getFeature
(
feature
)).
numCandidates
(
Constant
.
BODY_MATCH_RESULT_SIZE
);
queries
.
add
(
new
Query
.
Builder
().
exists
(
s
->
s
.
field
(
"body"
).
boost
(
1.0f
)).
build
());
}
//根据mallId过滤
if
(
person
.
getMallId
()
!=
null
)
{
// boolQuery.filter().add(QueryBuilders.termQuery("mallId", person.getMallId()));
queries
.
add
(
QueryBuilders
.
term
().
field
(
"mallId"
).
value
(
person
.
getMallId
()).
build
().
_toQuery
());
}
//
if (person.getMallId() != null) {
//
//
boolQuery.filter().add(QueryBuilders.termQuery("mallId", person.getMallId()));
//
queries.add(QueryBuilders.term().field("mallId").value(person.getMallId()).build()._toQuery());
//
}
// 根据通道号过滤
List
<
String
>
channelSerialNums
=
person
.
getChannelSerialNums
();
if
(
CollectionUtils
.
isNotEmpty
(
channelSerialNums
))
{
...
...
@@ -568,7 +572,7 @@ public class PersonService {
private
SearchRequest
getSearchRequest
(
String
rid
,
String
poolId
,
Integer
matchResultSize
,
Double
[]
feature
,
Person
person
,
int
type
,
Boolean
agg
)
{
// BoolQuery.Builder builder = getSearchSourceBuilder(feature, person, type);
Query
scriptScoreQuery
=
getScriptScoreQuery
(
feature
,
person
,
1
);
Query
scriptScoreQuery
=
getScriptScoreQuery
(
feature
,
person
,
type
);
if
(
agg
)
{
// AggregationBuilders.max("max_score", s -> s.field("_score").script(new Script.Builder().source("_score").build()));
// Aggregation aggregation = AggregationBuilders.max(s -> s.field("max_score").script(new Script.Builder().source("_score").build()));
...
...
@@ -594,7 +598,13 @@ public class PersonService {
// log.debug("rid:{} poolId:{} 匹配时参数:{}", rid, poolId, scriptScoreQuery.toString());
// KnnSearch knnQuery = getKnnSearch(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
();
double
minScore
=
0.0
;
if
(
type
==
0
)
{
minScore
=
person
.
getFaceMinScore
().
doubleValue
()/
100
;
}
else
if
(
type
==
1
)
{
minScore
=
person
.
getBodyMinScore
().
doubleValue
()/
100
;
}
return
new
SearchRequest
.
Builder
().
index
(
poolId
).
query
(
scriptScoreQuery
).
source
(
sourceConfig
).
size
(
matchResultSize
).
minScore
(
minScore
).
build
();
}
private
List
<
Person
>
match0
(
SearchRequest
searchRequest
,
Boolean
agg
)
throws
Exception
{
...
...
@@ -631,7 +641,7 @@ public class PersonService {
p
.
setCounttime
(
Optional
.
ofNullable
((
String
)
hit
.
getCounttime
())
.
map
(
x
->
{
try
{
return
Constant
.
DATE_FORMAT
.
get
().
parse
(
x
);
return
Constant
.
DATE_FORMAT
.
get
().
parse
(
x
);
}
catch
(
ParseException
e
)
{
return
null
;
}
...
...
@@ -643,6 +653,7 @@ public class PersonService {
persons
.
add
(
p
);
}
}
return
persons
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment