Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
vion-label
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 a5067a9d
authored
Sep 08, 2021
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优质todo,合并后再搜索时进行隐藏
1 parent
124ae36c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
11 deletions
label-core/src/main/java/com/viontech/label/core/constant/SubTaskStatus.java
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
label-platform/src/main/java/com/viontech/label/platform/utils/StorageUtils.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/controller/KeliuController.java
label-core/src/main/java/com/viontech/label/core/constant/SubTaskStatus.java
View file @
a5067a9
...
...
@@ -13,6 +13,8 @@ public enum SubTaskStatus {
LABELING
(
2
),
/** 完成标注 */
FINISH_LABELING
(
3
),
/** todo标注 */
TODO
(
4
),
/** 已回收 */
recycled
(-
1
);
public
int
val
;
...
...
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
View file @
a5067a9
...
...
@@ -142,6 +142,19 @@ public class ReidController {
}
}
@GetMapping
(
"/mergeAndTodo"
)
public
Object
mergeAndTodo
(
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
[]
personUnidArr
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
Long
[]
subTaskIdArr
,
@RequestParam
Long
packId
,
@RequestParam
String
currentPerson
)
{
try
{
reidService
.
mergeAndTodo
(
personUnidArr
,
subTaskIdArr
,
packId
,
currentPerson
);
}
catch
(
Exception
e
)
{
return
JsonMessageUtil
.
getErrorJsonMsg
(
e
.
getMessage
());
}
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
);
}
/**
* 标记某个人已经被清理干净了
*
...
...
@@ -162,8 +175,10 @@ public class ReidController {
* @param size 获取相似的人的数量
*/
@GetMapping
(
"/getSimilarPerson"
)
public
Object
getSimilarPerson
(
@RequestParam
Long
[]
picIdArr
,
@RequestParam
Long
packId
,
@RequestParam
Long
size
,
@RequestParam
(
required
=
false
)
Integer
timeInterval
)
{
Map
<
String
,
List
<
SubTask
>>
similarPerson
=
reidService
.
getSimilarPerson
(
picIdArr
,
packId
,
size
,
timeInterval
);
public
Object
getSimilarPerson
(
@RequestParam
Long
[]
picIdArr
,
@RequestParam
Long
packId
,
@RequestParam
Long
size
,
@RequestParam
(
required
=
false
)
Integer
timeInterval
,
@RequestParam
(
required
=
false
)
String
currentPerson
)
{
Map
<
String
,
Map
<
String
,
List
<
SubTask
>>>
similarPerson
=
reidService
.
getSimilarPerson
(
picIdArr
,
packId
,
size
,
timeInterval
,
currentPerson
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
,
similarPerson
);
}
...
...
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
View file @
a5067a9
...
...
@@ -21,7 +21,9 @@ import com.viontech.label.platform.vo.PicVo;
import
com.viontech.label.platform.vo.ReidUploadData
;
import
com.viontech.label.platform.websocket.ReidWebsocket
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.redisson.api.RMap
;
import
org.redisson.api.RSet
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
@@ -138,7 +140,7 @@ public class ReidService {
/**
* 将多个人合并
*/
public
void
mergePerson
(
String
[]
personUnidArr
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
public
String
mergePerson
(
String
[]
personUnidArr
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
String
newPersonUnid
;
ArrayList
<
String
>
needMergePersonUnidList
=
new
ArrayList
<>(
Arrays
.
asList
(
personUnidArr
));
if
(
currentPerson
!=
null
&&
needMergePersonUnidList
.
contains
(
currentPerson
))
{
...
...
@@ -199,13 +201,15 @@ public class ReidService {
logMergePerson
(
personUnidArr
);
// websocket
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergePerson"
).
setData
(
needMergePersonUnidList
));
return
newPersonUnid
;
}
/**
* 合并多张图作为新人
*/
public
void
mergeAsNewPerson
(
Long
[]
subTaskIds
,
Long
packId
)
throws
Exception
{
public
String
mergeAsNewPerson
(
Long
[]
subTaskIds
,
Long
packId
)
throws
Exception
{
String
poolName
=
Constants
.
getReidPoolName
(
packId
);
// 获取被合并的图片对应的personUnid集合
SubTaskExample
subTaskExample
=
new
SubTaskExample
();
...
...
@@ -264,12 +268,14 @@ public class ReidService {
logMergeAsNewPerson
(
subTaskIds
);
// websocket
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergeAsNewPerson"
).
setData
(
message
));
return
newPersonUnid
;
}
/**
* 将多张图与某个人合并
*/
public
void
mergeTo
(
Long
[]
subTaskIdArr
,
String
personUnid
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
public
String
mergeTo
(
Long
[]
subTaskIdArr
,
String
personUnid
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
if
(!
Objects
.
equals
(
personUnid
,
currentPerson
))
{
if
(
isLabeling
(
personUnid
,
packId
)
!=
null
)
{
throw
new
RuntimeException
(
"有标注中的人被选择"
);
...
...
@@ -302,6 +308,11 @@ public class ReidService {
for
(
Long
picId
:
picIdSet
)
{
storageUtils
.
removePicCache
(
picId
);
}
// 合并后将 personUnid 放入到redis 的过滤列表中
if
(
currentPerson
.
equals
(
personUnid
))
{
addMatchFilter
(
personUnid
,
packId
,
originalPersonUnidSet
);
}
// 写入日志
logMergeTo
(
subTaskIdArr
,
personUnid
);
// websocket
...
...
@@ -309,6 +320,61 @@ public class ReidService {
body
.
put
(
"subTaskIdArr"
,
subTaskIdArr
);
body
.
put
(
"personUnid"
,
personUnid
);
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergeTo"
).
setData
(
body
));
return
personUnid
;
}
/**
* 按规则合并,并跟新为todo 状态
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
mergeAndTodo
(
String
[]
personUnidArr
,
Long
[]
subTaskIdArr
,
Long
packId
,
String
currentPerson
)
throws
Exception
{
log
.
info
(
"mergeAndTodo:[{}]-[{}]-[{}]-[{}]"
,
Arrays
.
toString
(
personUnidArr
),
Arrays
.
toString
(
subTaskIdArr
),
packId
,
currentPerson
);
int
i
=
ArrayUtils
.
indexOf
(
personUnidArr
,
currentPerson
);
if
(
i
!=
-
1
)
{
personUnidArr
=
ArrayUtils
.
remove
(
personUnidArr
,
i
);
}
String
type
=
""
;
if
(
personUnidArr
.
length
>
1
&&
subTaskIdArr
.
length
>
1
)
{
throw
new
RuntimeException
(
"参数不正确"
);
}
if
(
personUnidArr
.
length
==
1
)
{
if
(
subTaskIdArr
.
length
>
0
)
{
type
=
"mergeTo"
;
}
else
{
type
=
"update"
;
}
}
else
if
(
personUnidArr
.
length
==
0
&&
subTaskIdArr
.
length
>
0
)
{
type
=
"mergeAsNewPerson"
;
}
else
if
(
personUnidArr
.
length
>
1
&&
subTaskIdArr
.
length
==
0
)
{
type
=
"mergePerson"
;
}
String
personUnid
;
switch
(
type
)
{
case
"mergeTo"
:
personUnid
=
mergeTo
(
subTaskIdArr
,
personUnidArr
[
0
],
currentPerson
,
packId
);
break
;
case
"mergeAsNewPerson"
:
personUnid
=
mergeAsNewPerson
(
subTaskIdArr
,
packId
);
break
;
case
"mergePerson"
:
personUnid
=
mergePerson
(
personUnidArr
,
currentPerson
,
packId
);
break
;
case
"update"
:
personUnid
=
personUnidArr
[
0
];
break
;
default
:
throw
new
RuntimeException
(
"未知原因"
);
}
SubTaskExample
subTaskExample
=
new
SubTaskExample
();
subTaskExample
.
createCriteria
().
andPersonUnidEqualTo
(
personUnid
).
andPackIdEqualTo
(
packId
);
SubTask
subTask
=
new
SubTask
();
subTask
.
setStatus
(
SubTaskStatus
.
TODO
.
val
);
subTaskService
.
updateByExampleSelective
(
subTask
,
subTaskExample
);
}
/**
...
...
@@ -352,7 +418,7 @@ public class ReidService {
/**
* 根据所选择的图片获取相似的人
*/
public
Map
<
String
,
List
<
SubTask
>>
getSimilarPerson
(
Long
[]
subTaskIdArr
,
Long
packId
,
Long
size
,
Integer
timeInterval
)
{
public
Map
<
String
,
Map
<
String
,
List
<
SubTask
>>>
getSimilarPerson
(
Long
[]
subTaskIdArr
,
Long
packId
,
Long
size
,
Integer
timeInterval
,
String
currentPerson
)
{
List
<
BodyFeature
>
bodyFeatures
=
new
ArrayList
<>();
String
reidPoolName
=
Constants
.
getReidPoolName
(
packId
);
Date
countTimeGTE
=
null
;
...
...
@@ -402,16 +468,28 @@ public class ReidService {
subTaskExample
.
createCriteria
().
andPersonUnidIn
(
personUnidList
);
subTasks
=
subTaskService
.
selectByExample
(
subTaskExample
);
final
Set
<
String
>
matchFilter
=
currentPerson
==
null
?
Collections
.
emptySet
()
:
getMatchFilter
(
currentPerson
,
packId
);
Map
<
String
,
List
<
SubTask
>>
collect
=
subTasks
.
stream
().
collect
(
Collectors
.
groupingBy
(
SubTask:
:
getPersonUnid
,
Collectors
.
toList
()));
HashMap
<
String
,
Map
<
String
,
List
<
SubTask
>>>
ret
=
new
HashMap
<>();
Map
<
String
,
List
<
SubTask
>>
hideMap
=
new
HashMap
<>();
Map
<
String
,
List
<
SubTask
>>
displayMap
=
new
HashMap
<>();
ret
.
put
(
"hide"
,
hideMap
);
ret
.
put
(
"display"
,
displayMap
);
for
(
Map
.
Entry
<
String
,
List
<
SubTask
>>
entry
:
collect
.
entrySet
())
{
SubTask
pic
=
entry
.
getValue
().
get
(
0
);
if
(
pic
.
getStatus
()
==
SubTaskStatus
.
FINISH_LABELING
.
val
&&
entry
.
getValue
().
size
()
>
3
)
{
entry
.
setValue
(
entry
.
getValue
().
subList
(
0
,
3
));
}
if
(
matchFilter
.
contains
(
pic
.
getPersonUnid
()))
{
hideMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
else
{
displayMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
return
collec
t
;
return
re
t
;
}
catch
(
Exception
e
)
{
log
.
info
(
""
,
e
);
return
null
;
...
...
@@ -734,6 +812,19 @@ public class ReidService {
}
}
private
void
addMatchFilter
(
String
personUnid
,
Long
packId
,
Collection
<
String
>
filters
)
{
if
(
filters
.
size
()
>
0
)
{
RSet
<
String
>
set
=
redissonClient
.
getSet
(
"matchFilter:"
+
packId
+
":"
+
personUnid
);
set
.
addAll
(
filters
);
set
.
expire
(
1
,
TimeUnit
.
DAYS
);
}
}
private
Set
<
String
>
getMatchFilter
(
String
personUnid
,
Long
packId
)
{
RSet
<
String
>
set
=
redissonClient
.
getSet
(
"matchFilter:"
+
packId
+
":"
+
personUnid
);
return
set
.
readAll
();
}
public
LogService
getLogService
()
{
return
logService
;
}
...
...
label-platform/src/main/java/com/viontech/label/platform/utils/StorageUtils.java
View file @
a5067a9
...
...
@@ -75,7 +75,7 @@ public class StorageUtils {
// 获取并缓存 image
Long
packId
=
picVo
.
getPackId
();
String
picImageKey
=
Constants
.
getRedisKeyPicImage
(
picId
);
RBucket
<
byte
[]>
picImageBucket
=
redissonClient
.
<
byte
[]>
getBucket
(
picImageKey
);
RBucket
<
byte
[]>
picImageBucket
=
redissonClient
.
getBucket
(
picImageKey
);
byte
[]
bytes
=
picImageBucket
.
get
();
if
(
bytes
==
null
)
{
try
{
...
...
@@ -86,7 +86,7 @@ public class StorageUtils {
}
picImageBucket
.
set
(
bytes
);
}
picImageBucket
.
expire
(
12
,
TimeUnit
.
HOURS
);
picImageBucket
.
expire
(
4
,
TimeUnit
.
HOURS
);
picVo
.
setImage
(
bytes
);
return
picVo
;
...
...
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/controller/KeliuController.java
View file @
a5067a9
...
...
@@ -26,6 +26,7 @@ import java.util.concurrent.Future;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
* .
...
...
@@ -63,6 +64,7 @@ public class KeliuController {
SEND_DATA
=
true
;
ThreadPoolExecutor
threadPoolExecutor
=
new
ThreadPoolExecutor
(
20
,
20
,
1
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>(
10000
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
try
{
AtomicLong
count
=
new
AtomicLong
();
List
<
FaceRecognition
>
faceRecognitions
=
keliuRepository
.
getFaceRecognitionsByDateAndMallId
(
date
,
mallId
);
for
(
FaceRecognition
faceRecognition
:
faceRecognitions
)
{
Future
<
JsonMessageUtil
.
JsonMessage
>
submit
=
threadPoolExecutor
.
submit
(()
->
{
...
...
@@ -72,7 +74,7 @@ public class KeliuController {
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
getRequestEntity
(
faceRecognition
,
bodyPic
,
bodyFeature
,
packId
,
taskId
);
ResponseEntity
<
JsonMessageUtil
.
JsonMessage
>
exchange
=
restTemplate
.
exchange
(
vionConfig
.
getTargetUrl
(),
HttpMethod
.
POST
,
requestEntity
,
JsonMessageUtil
.
JsonMessage
.
class
);
JsonMessageUtil
.
JsonMessage
body
=
exchange
.
getBody
();
log
.
info
(
"unid:{},msg:{}
"
,
faceRecognition
.
getUnid
(),
body
.
getMsg
());
log
.
info
(
"unid:{},msg:{}
,count:{}/{}"
,
faceRecognition
.
getUnid
(),
body
.
getMsg
(),
count
.
incrementAndGet
(),
faceRecognitions
.
size
());
return
body
;
}
catch
(
Exception
e
)
{
log
.
info
(
""
,
e
);
...
...
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