Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
fce66be9
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fce66be9
编写于
11月 13, 2021
作者:
W
wangguanzhong
提交者:
GitHub
11月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add draw_center_traj (#4567)
* add draw_center_traj
上级
7826f247
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
4 deletion
+32
-4
deploy/pptracking/python/mot_jde_infer.py
deploy/pptracking/python/mot_jde_infer.py
+10
-3
deploy/pptracking/python/utils.py
deploy/pptracking/python/utils.py
+4
-0
deploy/pptracking/python/visualize.py
deploy/pptracking/python/visualize.py
+18
-1
未找到文件。
deploy/pptracking/python/mot_jde_infer.py
浏览文件 @
fce66be9
...
...
@@ -220,6 +220,11 @@ def predict_video(detector, camera_id):
num_classes
=
detector
.
num_classes
data_type
=
'mcmot'
if
num_classes
>
1
else
'mot'
ids2names
=
detector
.
pred_config
.
labels
center_traj
=
None
entrance
=
None
records
=
None
if
FLAGS
.
draw_center_traj
:
center_traj
=
{}
if
num_classes
==
1
:
id_set
=
set
()
...
...
@@ -231,6 +236,7 @@ def predict_video(detector, camera_id):
entrance
=
[
0
,
height
/
2.
,
width
,
height
/
2.
]
video_fps
=
fps
while
(
1
):
ret
,
frame
=
capture
.
read
()
if
not
ret
:
...
...
@@ -260,10 +266,9 @@ def predict_video(detector, camera_id):
prev_center
=
statistic
[
'prev_center'
]
records
=
statistic
[
'records'
]
elif
num_classes
>
1
and
do_entrance_counting
:
elif
num_classes
>
1
and
FLAGS
.
do_entrance_counting
:
raise
NotImplementedError
(
'Multi-class flow counting is not implemented now!'
)
im
=
plot_tracking_dict
(
frame
,
num_classes
,
...
...
@@ -274,7 +279,9 @@ def predict_video(detector, camera_id):
fps
=
fps
,
ids2names
=
ids2names
,
do_entrance_counting
=
FLAGS
.
do_entrance_counting
,
entrance
=
entrance
)
entrance
=
entrance
,
records
=
records
,
center_traj
=
center_traj
)
if
FLAGS
.
save_images
:
save_dir
=
os
.
path
.
join
(
FLAGS
.
output_dir
,
video_name
.
split
(
'.'
)[
-
2
])
...
...
deploy/pptracking/python/utils.py
浏览文件 @
fce66be9
...
...
@@ -131,6 +131,10 @@ def argsparser():
type
=
int
,
default
=
10
,
help
=
"The seconds interval to count after tracking"
)
parser
.
add_argument
(
"--draw_center_traj"
,
action
=
'store_true'
,
help
=
"Whether drawing the trajectory of center"
)
return
parser
...
...
deploy/pptracking/python/visualize.py
浏览文件 @
fce66be9
...
...
@@ -20,6 +20,7 @@ import cv2
import
numpy
as
np
from
PIL
import
Image
,
ImageDraw
import
math
from
collections
import
deque
def
visualize_box_mask
(
im
,
results
,
labels
,
threshold
=
0.5
):
...
...
@@ -198,7 +199,9 @@ def plot_tracking_dict(image,
fps
=
0.
,
ids2names
=
[],
do_entrance_counting
=
False
,
entrance
=
None
):
entrance
=
None
,
records
=
None
,
center_traj
=
None
):
im
=
np
.
ascontiguousarray
(
np
.
copy
(
image
))
im_h
,
im_w
=
im
.
shape
[:
2
]
...
...
@@ -222,10 +225,17 @@ def plot_tracking_dict(image,
text_scale
,
(
0
,
0
,
255
),
thickness
=
2
)
record_id
=
set
()
for
i
,
tlwh
in
enumerate
(
tlwhs
):
x1
,
y1
,
w
,
h
=
tlwh
intbox
=
tuple
(
map
(
int
,
(
x1
,
y1
,
x1
+
w
,
y1
+
h
)))
center
=
tuple
(
map
(
int
,
(
x1
+
w
/
2.
,
y1
+
h
/
2.
)))
obj_id
=
int
(
obj_ids
[
i
])
if
center_traj
is
not
None
:
record_id
.
add
(
obj_id
)
if
obj_id
not
in
center_traj
:
center_traj
[
obj_id
]
=
deque
(
maxlen
=
30
)
center_traj
[
obj_id
].
append
(
center
)
id_text
=
'{}'
.
format
(
int
(
obj_id
))
if
ids2names
!=
[]:
...
...
@@ -264,4 +274,11 @@ def plot_tracking_dict(image,
entrance_line
[
2
:
4
],
color
=
(
0
,
255
,
255
),
thickness
=
line_thickness
)
if
center_traj
is
not
None
:
for
i
in
center_traj
.
keys
():
if
i
not
in
record_id
:
continue
for
point
in
center_traj
[
i
]:
cv2
.
circle
(
im
,
point
,
3
,
(
0
,
0
,
255
),
-
1
)
return
im
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录