Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
2827bc31
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2827bc31
编写于
10月 12, 2022
作者:
Z
zhiboniu
提交者:
GitHub
10月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eliminate capture video time cost (#7096)
* fix time count while less than warmupframe * eliminate capture video time cost
上级
ec697920
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
9 deletion
+29
-9
deploy/pipeline/pipeline.py
deploy/pipeline/pipeline.py
+29
-9
未找到文件。
deploy/pipeline/pipeline.py
浏览文件 @
2827bc31
...
@@ -21,6 +21,9 @@ import math
...
@@ -21,6 +21,9 @@ import math
import
paddle
import
paddle
import
sys
import
sys
import
copy
import
copy
import
threading
import
queue
import
time
from
collections
import
Sequence
,
defaultdict
from
collections
import
Sequence
,
defaultdict
from
datacollector
import
DataCollector
,
Result
from
datacollector
import
DataCollector
,
Result
...
@@ -139,7 +142,6 @@ class Pipeline(object):
...
@@ -139,7 +142,6 @@ class Pipeline(object):
return
input
return
input
def
run_multithreads
(
self
):
def
run_multithreads
(
self
):
import
threading
if
self
.
multi_camera
:
if
self
.
multi_camera
:
multi_res
=
[]
multi_res
=
[]
threads
=
[]
threads
=
[]
...
@@ -572,6 +574,18 @@ class PipePredictor(object):
...
@@ -572,6 +574,18 @@ class PipePredictor(object):
if
self
.
cfg
[
'visual'
]:
if
self
.
cfg
[
'visual'
]:
self
.
visualize_image
(
batch_file
,
batch_input
,
self
.
pipeline_res
)
self
.
visualize_image
(
batch_file
,
batch_input
,
self
.
pipeline_res
)
def
capturevideo
(
self
,
capture
,
queue
):
frame_id
=
0
while
(
1
):
if
queue
.
full
():
time
.
sleep
(
0.1
)
else
:
ret
,
frame
=
capture
.
read
()
if
not
ret
:
return
frame_rgb
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2RGB
)
queue
.
put
(
frame_rgb
)
def
predict_video
(
self
,
video_file
,
thread_idx
=
0
):
def
predict_video
(
self
,
video_file
,
thread_idx
=
0
):
# mot
# mot
# mot -> attr
# mot -> attr
...
@@ -647,14 +661,19 @@ class PipePredictor(object):
...
@@ -647,14 +661,19 @@ class PipePredictor(object):
}
# store info for vehicle parking in region
}
# store info for vehicle parking in region
illegal_parking_dict
=
None
illegal_parking_dict
=
None
while
(
1
):
framequeue
=
queue
.
Queue
(
10
)
thread
=
threading
.
Thread
(
target
=
self
.
capturevideo
,
args
=
(
capture
,
framequeue
))
thread
.
start
()
time
.
sleep
(
1
)
while
(
not
framequeue
.
empty
()):
if
frame_id
%
10
==
0
:
if
frame_id
%
10
==
0
:
print
(
'Thread: {}; frame id: {}'
.
format
(
thread_idx
,
frame_id
))
print
(
'Thread: {}; frame id: {}'
.
format
(
thread_idx
,
frame_id
))
ret
,
frame
=
capture
.
read
()
frame_rgb
=
framequeue
.
get
()
if
not
ret
:
break
frame_rgb
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2RGB
)
if
frame_id
>
self
.
warmup_frame
:
if
frame_id
>
self
.
warmup_frame
:
self
.
pipe_timer
.
total_time
.
start
()
self
.
pipe_timer
.
total_time
.
start
()
...
@@ -720,7 +739,7 @@ class PipePredictor(object):
...
@@ -720,7 +739,7 @@ class PipePredictor(object):
self
.
pipe_timer
.
total_time
.
end
()
self
.
pipe_timer
.
total_time
.
end
()
if
self
.
cfg
[
'visual'
]:
if
self
.
cfg
[
'visual'
]:
_
,
_
,
fps
=
self
.
pipe_timer
.
get_total_time
()
_
,
_
,
fps
=
self
.
pipe_timer
.
get_total_time
()
im
=
self
.
visualize_video
(
frame
,
mot_res
,
frame_id
,
fps
,
im
=
self
.
visualize_video
(
frame
_rgb
,
mot_res
,
frame_id
,
fps
,
entrance
,
records
,
entrance
,
records
,
center_traj
)
# visualize
center_traj
)
# visualize
if
len
(
self
.
pushurl
)
>
0
:
if
len
(
self
.
pushurl
)
>
0
:
...
@@ -894,7 +913,7 @@ class PipePredictor(object):
...
@@ -894,7 +913,7 @@ class PipePredictor(object):
if
self
.
cfg
[
'visual'
]:
if
self
.
cfg
[
'visual'
]:
_
,
_
,
fps
=
self
.
pipe_timer
.
get_total_time
()
_
,
_
,
fps
=
self
.
pipe_timer
.
get_total_time
()
im
=
self
.
visualize_video
(
frame
,
self
.
pipeline_res
,
im
=
self
.
visualize_video
(
frame
_rgb
,
self
.
pipeline_res
,
self
.
collector
,
frame_id
,
fps
,
self
.
collector
,
frame_id
,
fps
,
entrance
,
records
,
center_traj
,
entrance
,
records
,
center_traj
,
self
.
illegal_parking_time
!=
-
1
,
self
.
illegal_parking_time
!=
-
1
,
...
@@ -912,7 +931,7 @@ class PipePredictor(object):
...
@@ -912,7 +931,7 @@ class PipePredictor(object):
print
(
'save result to {}'
.
format
(
out_path
))
print
(
'save result to {}'
.
format
(
out_path
))
def
visualize_video
(
self
,
def
visualize_video
(
self
,
image
,
image
_rgb
,
result
,
result
,
collector
,
collector
,
frame_id
,
frame_id
,
...
@@ -922,6 +941,7 @@ class PipePredictor(object):
...
@@ -922,6 +941,7 @@ class PipePredictor(object):
center_traj
=
None
,
center_traj
=
None
,
do_illegal_parking_recognition
=
False
,
do_illegal_parking_recognition
=
False
,
illegal_parking_dict
=
None
):
illegal_parking_dict
=
None
):
image
=
cv2
.
cvtColor
(
image_rgb
,
cv2
.
COLOR_RGB2BGR
)
mot_res
=
copy
.
deepcopy
(
result
.
get
(
'mot'
))
mot_res
=
copy
.
deepcopy
(
result
.
get
(
'mot'
))
if
mot_res
is
not
None
:
if
mot_res
is
not
None
:
ids
=
mot_res
[
'boxes'
][:,
0
]
ids
=
mot_res
[
'boxes'
][:,
0
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录