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 484bcd36
authored
May 12, 2022
by
李乾广
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add]人员列表排序,过滤低质图片,获取body point
1 parent
7f6cb362
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
256 additions
and
14 deletions
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
label-platform/src/main/java/com/viontech/label/platform/mapper/SubTaskMapper.java
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
View file @
484bcd3
package
com
.
viontech
.
label
.
platform
.
controller
.
web
;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -9,7 +10,14 @@ import com.viontech.keliu.util.DateUtil;
import
com.viontech.keliu.util.JsonMessageUtil
;
import
com.viontech.label.platform.mapper.LogMapper
;
import
com.viontech.label.platform.mapper.SubTaskMapper
;
import
com.viontech.label.platform.model.*
;
import
com.viontech.label.platform.model.Account
;
import
com.viontech.label.platform.model.Pack
;
import
com.viontech.label.platform.model.PackExample
;
import
com.viontech.label.platform.model.SubTask
;
import
com.viontech.label.platform.model.SubTaskExample
;
import
com.viontech.label.platform.model.Task
;
import
com.viontech.label.platform.model.TaskExample
;
import
com.viontech.label.platform.model.User
;
import
com.viontech.label.platform.service.adapter.PackService
;
import
com.viontech.label.platform.service.adapter.SubTaskService
;
import
com.viontech.label.platform.service.adapter.TaskService
;
...
...
@@ -19,13 +27,25 @@ import com.viontech.label.platform.vo.ReidUploadData;
import
com.viontech.label.platform.vo.SubTaskVo
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -67,26 +87,30 @@ public class ReidController {
SubTaskMapper
mapper
=
(
SubTaskMapper
)
subTaskService
.
getMapper
();
List
<
String
>
personUnids
=
mapper
.
getPersonUnids
(
packId
,
status
,
page
==
null
?
null
:
(
page
-
1
)
*
size
,
size
,
annotatorId
,
countGTE
,
countLTE
);
List
<
SubTaskVo
>
people
=
personUnids
.
size
()
==
0
?
Collections
.
emptyList
()
:
mapper
.
getPeople
(
packId
,
personUnids
);
List
<
SubTaskVo
>
people
=
CollUtil
.
isEmpty
(
personUnids
)
?
Collections
.
emptyList
()
:
mapper
.
getPeople
(
packId
,
personUnids
);
LinkedHashMap
<
String
,
List
<
SubTaskVo
>>
temp
=
new
LinkedHashMap
<>();
Map
<
String
,
User
>
labelingMap
=
reidService
.
getRedissonClient
().<
String
,
User
>
getMap
(
"labeling:"
+
packId
).
readAllMap
();
for
(
SubTaskVo
item
:
people
)
{
String
personUnid
=
item
.
getPersonUnid
();
List
<
SubTaskVo
>
list
=
temp
.
computeIfAbsent
(
personUnid
,
x
->
new
LinkedList
<>());
list
.
add
(
item
);
if
(
labelingMap
.
containsKey
(
personUnid
))
{
item
.
setLabelUserName
(
labelingMap
.
get
(
personUnid
).
getName
());
}
}
Map
<
String
,
List
<
SubTaskVo
>>
personMap
=
people
.
stream
().
collect
(
Collectors
.
groupingBy
(
SubTaskVo:
:
getPersonUnid
));
List
<
Map
<
String
,
List
<
SubTaskVo
>>>
result
=
new
ArrayList
<>(
personMap
.
size
());
for
(
String
personUnid
:
personUnids
)
{
Map
<
String
,
List
<
SubTaskVo
>>
item
=
new
HashMap
<>(
1
);
item
.
put
(
personUnid
,
personMap
.
get
(
personUnid
));
result
.
add
(
item
);
}
if
(
page
!=
null
)
{
PageInfo
<
Object
>
pageInfo
=
new
PageInfo
<>(
new
ArrayList
<>(
temp
.
entrySet
())
,
page
.
intValue
());
PageInfo
<
Map
<
String
,
List
<
SubTaskVo
>>>
pageInfo
=
new
PageInfo
<>(
result
,
page
.
intValue
());
pageInfo
.
setTotal
(
mapper
.
countPeople
(
packId
,
status
,
annotatorId
,
countGTE
,
countLTE
));
return
JsonMessageUtil
.
getSuccessJsonMsg
(
pageInfo
);
}
else
{
return
JsonMessageUtil
.
getSuccessJsonMsg
(
temp
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
result
);
}
}
...
...
@@ -349,4 +373,14 @@ public class ReidController {
return
JsonMessageUtil
.
getSuccessJsonMsg
();
}
/**
* 获取body point坐标
* @param picId
* @return
*/
@GetMapping
(
"/bodyPoint"
)
public
Object
getBodyPoint
(
@RequestParam
(
name
=
"picId"
)
Long
picId
)
{
return
reidService
.
getBodyPoint
(
picId
);
}
}
label-platform/src/main/java/com/viontech/label/platform/mapper/SubTaskMapper.java
View file @
484bcd3
...
...
@@ -73,7 +73,7 @@ public interface SubTaskMapper extends BaseMapper {
" <if test = 'annotatorId != null'> and annotator_id = #{annotatorId}</if> "
+
"group by person_unid "
+
" having count(*) between #{countGTE} and #{countLTE} "
+
" order by person_unid "
+
" order by
min(create_time),
person_unid "
+
"<if test='offset != null'> offset #{offset} limit #{limit}</if>"
+
"</script>"
)
List
<
String
>
getPersonUnids
(
Long
packId
,
Integer
status
,
Long
offset
,
Long
limit
,
Long
annotatorId
,
Integer
countGTE
,
Integer
countLTE
);
...
...
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
View file @
484bcd3
...
...
@@ -4,14 +4,24 @@ import cn.dev33.satoken.stp.StpUtil;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Lists
;
import
com.viontech.keliu.model.*
;
import
com.viontech.keliu.model.AlgResult
;
import
com.viontech.keliu.model.BodyFeature
;
import
com.viontech.keliu.model.Data
;
import
com.viontech.keliu.model.Feature
;
import
com.viontech.keliu.model.Person
;
import
com.viontech.keliu.util.DateUtil
;
import
com.viontech.keliu.util.JsonMessageUtil
;
import
com.viontech.keliu.websocket.AlgApiClient
;
import
com.viontech.label.core.constant.Constants
;
import
com.viontech.label.core.constant.LogOperateType
;
import
com.viontech.label.core.constant.SubTaskStatus
;
import
com.viontech.label.platform.mapper.SubTaskMapper
;
import
com.viontech.label.platform.model.*
;
import
com.viontech.label.platform.model.Log
;
import
com.viontech.label.platform.model.Pack
;
import
com.viontech.label.platform.model.Pic
;
import
com.viontech.label.platform.model.SubTask
;
import
com.viontech.label.platform.model.SubTaskExample
;
import
com.viontech.label.platform.model.User
;
import
com.viontech.label.platform.service.adapter.LogService
;
import
com.viontech.label.platform.service.adapter.PicService
;
import
com.viontech.label.platform.service.adapter.SubTaskService
;
...
...
@@ -34,7 +44,18 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
...
...
@@ -599,6 +620,10 @@ public class ReidService {
for
(
Map
.
Entry
<
String
,
List
<
SubTask
>>
entry
:
collect
.
entrySet
())
{
SubTask
pic
=
entry
.
getValue
().
get
(
0
);
//跳过低质图片
if
(
pic
.
getStatus
()
==
SubTaskStatus
.
LOW_QUALITY
.
val
)
{
continue
;
}
if
(
pic
.
getStatus
()
==
SubTaskStatus
.
FINISH_LABELING
.
val
&&
entry
.
getValue
().
size
()
>
3
)
{
entry
.
setValue
(
entry
.
getValue
().
subList
(
0
,
3
));
}
...
...
@@ -978,4 +1003,187 @@ public class ReidService {
public
RedissonClient
getRedissonClient
()
{
return
redissonClient
;
}
/**
* 获取body point
* @param picId
* @return
*/
public
Object
getBodyPoint
(
Long
picId
)
{
if
(
null
==
picId
)
{
return
JsonMessageUtil
.
getErrorJsonMsg
(
"picId不能为空"
);
}
Feature
feature
=
storageUtils
.
getFeatureByPic
(
picId
);
if
(
null
==
feature
)
{
JsonMessageUtil
.
getErrorJsonMsg
(
"获取特征失败"
);
}
Integer
image_w
=
1920
;
Integer
image_h
=
1080
;
double
zero_point
[]
=
{
0
,
0
};
Integer
quadrant
=
0
;
try
{
double
cx
=
feature
.
getFace_roi
().
get
(
0
).
getX
();
double
cy
=
feature
.
getFace_roi
().
get
(
0
).
getY
();
double
foot_x
=
feature
.
getFace_roi
().
get
(
0
).
getW
();
double
foot_y
=
feature
.
getFace_roi
().
get
(
0
).
getH
();
Integer
img_type
=
feature
.
getBody_roi
().
get
(
0
).
getX
();
double
gap
=
0
;
// 计算图像位置
if
(
cx
>
image_w
/
2
+
420
)
{
quadrant
=
1
;
}
else
if
(
cx
<
image_w
/
2
-
420
)
{
quadrant
=
3
;
}
else
if
(
cy
>
image_h
/
2
)
{
quadrant
=
2
;
}
Integer
bodyWidth
=
80
;
Integer
headSize
=
120
;
Integer
basic_length
=
340
;
if
(
img_type
==
9999
)
{
bodyWidth
=
120
;
headSize
=
120
;
basic_length
=
380
;
}
if
(
cx
<
foot_x
)
{
cx
-=
headSize
;
foot_x
+=
bodyWidth
;
}
else
{
cx
+=
headSize
;
foot_x
-=
bodyWidth
;
}
if
(
cy
<
foot_y
)
{
cy
-=
headSize
;
foot_y
+=
bodyWidth
;
}
else
{
cy
+=
headSize
;
foot_y
-=
bodyWidth
;
}
if
(
cx
>
foot_x
)
{
gap
=
cx
-
foot_x
;
if
(
cx
-
foot_x
<=
basic_length
)
{
cx
=
cx
+
(
basic_length
-
gap
)
*
0.5
;
foot_x
=
foot_x
-
(
basic_length
-
gap
)
*
0.5
;
}
}
else
{
gap
=
foot_x
-
cx
;
if
(
foot_x
-
cx
<=
basic_length
)
{
cx
=
cx
-
(
basic_length
-
gap
)
*
0.5
;
foot_x
=
foot_x
+
(
basic_length
-
gap
)
*
0.5
;
}
}
if
(
cy
>
foot_y
)
{
gap
=
cy
-
foot_y
;
if
(
cy
-
foot_y
<=
basic_length
)
{
cy
=
cy
+
(
basic_length
-
gap
)
*
0.5
;
foot_y
=
foot_y
-
(
basic_length
-
gap
)
*
0.5
;
}
}
else
{
gap
=
foot_y
-
cy
;
if
(
foot_y
-
cy
<=
basic_length
)
{
cy
=
cy
-
(
basic_length
-
gap
)
*
0.5
;
foot_y
=
foot_y
+
(
basic_length
-
gap
)
*
0.5
;
}
}
double
body_left
=
cx
;
if
(
cx
>
foot_x
)
{
body_left
=
foot_x
;
}
double
body_right
=
cx
;
if
(
cx
<
foot_x
)
{
body_right
=
foot_x
;
}
double
body_top
=
cy
;
if
(
cy
>
foot_y
)
{
body_top
=
foot_y
;
}
double
body_bottom
=
cy
;
if
(
cy
<
foot_y
)
{
body_bottom
=
foot_y
;
}
//得到小图顶点在大图中的坐标
if
(
body_left
<
0
)
{
body_left
=
0
;
}
if
(
body_top
<
0
)
{
body_top
=
0
;
}
if
(
body_right
>
image_w
-
1
)
{
body_right
=
image_w
-
1
;
}
if
(
body_bottom
>
image_h
-
1
)
{
body_bottom
=
image_h
-
1
;
}
double
_cx
=
feature
.
getFace_roi
().
get
(
0
).
getX
();
double
_cy
=
feature
.
getFace_roi
().
get
(
0
).
getY
();
double
_foot_x
=
feature
.
getFace_roi
().
get
(
0
).
getW
();
double
_foot_y
=
feature
.
getFace_roi
().
get
(
0
).
getH
();
Integer
head_x_inSmall
=
0
;
Integer
head_y_inSmall
=
0
;
Integer
foot_x_inSmall
=
0
;
Integer
foot_y_inSmall
=
0
;
// 计算头脚在小图中的坐标
if
(
img_type
!=
9999
)
{
//顺时针旋转90度
if
(
quadrant
==
3
)
{
zero_point
[
0
]
=
body_left
;
zero_point
[
1
]
=
body_bottom
;
head_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_cy
)).
intValue
();
head_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_cx
)).
intValue
();
foot_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_foot_y
)).
intValue
();
foot_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_foot_x
)).
intValue
();
}
//顺时针旋转180度
else
if
(
quadrant
==
2
)
{
zero_point
[
0
]
=
body_right
;
zero_point
[
1
]
=
body_bottom
;
head_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_cx
)).
intValue
();
head_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_cy
)).
intValue
();
foot_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_foot_x
)).
intValue
();
foot_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_foot_y
)).
intValue
();
}
//顺时针旋转270度
else
if
(
quadrant
==
1
)
{
zero_point
[
0
]
=
body_right
;
zero_point
[
1
]
=
body_top
;
head_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_cy
)).
intValue
();
head_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_cx
)).
intValue
();
foot_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_foot_y
)).
intValue
();
foot_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_foot_x
)).
intValue
();
}
else
{
zero_point
[
0
]
=
body_left
;
zero_point
[
1
]
=
body_top
;
head_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_cx
)).
intValue
();
head_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_cy
)).
intValue
();
foot_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_foot_x
)).
intValue
();
foot_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_foot_y
)).
intValue
();
}
}
else
{
zero_point
[
0
]
=
body_left
;
zero_point
[
1
]
=
body_top
;
head_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_cx
)).
intValue
();
head_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_cy
)).
intValue
();
foot_x_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
0
]
-
_foot_x
)).
intValue
();
foot_y_inSmall
=
new
Double
(
Math
.
abs
(
zero_point
[
1
]
-
_foot_y
)).
intValue
();
}
Map
<
String
,
Integer
>
resultMap
=
new
HashMap
<>(
4
);
resultMap
.
put
(
"head_x_inSmall"
,
head_x_inSmall
);
resultMap
.
put
(
"head_y_inSmall"
,
head_y_inSmall
);
resultMap
.
put
(
"foot_x_inSmall"
,
foot_x_inSmall
);
resultMap
.
put
(
"foot_y_inSmall"
,
foot_y_inSmall
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
resultMap
);
}
catch
(
Exception
e
)
{
log
.
error
(
"获取坐标失败:{}"
,
e
.
getMessage
());
}
return
JsonMessageUtil
.
getErrorJsonMsg
(
"获取坐标失败"
);
}
}
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