Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_opencv
提交
acbd36a9
S
skill_tree_opencv
项目概览
CSDN 技术社区
/
skill_tree_opencv
通知
45
Star
9
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
acbd36a9
编写于
12月 16, 2021
作者:
F
feilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正车辆目标跟踪的路径bug
上级
cfdcccae
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
9 addition
and
5 deletion
+9
-5
data/1.OpenCV初阶/6.视频分析/2.目标跟踪/obj_tracker_run.py
data/1.OpenCV初阶/6.视频分析/2.目标跟踪/obj_tracker_run.py
+9
-5
未找到文件。
data/1.OpenCV初阶/6.视频分析/2.目标跟踪/obj_tracker_run.py
浏览文件 @
acbd36a9
...
@@ -19,6 +19,8 @@ tracks = np.empty((0, 5))
...
@@ -19,6 +19,8 @@ tracks = np.empty((0, 5))
sort
=
Sort
(
5
,
0
,
0.2
)
sort
=
Sort
(
5
,
0
,
0.2
)
# do track and render on image
# do track and render on image
def
track_and_render
(
detections
,
img
):
def
track_and_render
(
detections
,
img
):
global
total_frames
global
total_frames
global
total_time
global
total_time
...
@@ -40,7 +42,8 @@ def track_and_render(detections, img):
...
@@ -40,7 +42,8 @@ def track_and_render(detections, img):
cycle_time
=
time
.
time
()
-
start_time
cycle_time
=
time
.
time
()
-
start_time
total_time
+=
cycle_time
total_time
+=
cycle_time
if
total_frames
%
100
==
0
:
if
total_frames
%
100
==
0
:
print
(
"Total Tracking took: %.3f seconds for %d frames or %.1f FPS"
%
(
total_time
,
total_frames
,
total_frames
/
total_time
))
print
(
"Total Tracking took: %.3f seconds for %d frames or %.1f FPS"
%
(
total_time
,
total_frames
,
total_frames
/
total_time
))
total_time
=
0.0
total_time
=
0.0
total_frames
=
0
total_frames
=
0
...
@@ -63,18 +66,18 @@ def track_and_render(detections, img):
...
@@ -63,18 +66,18 @@ def track_and_render(detections, img):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# detection data, generated by object-detector algo model, including frame image
# detection data, generated by object-detector algo model, including frame image
path
=
'mot_benchmark
\\
MY_TEST
\\
www3'
path
=
'mot_benchmark
/MY_TEST/
www3'
# read test data from disk in a loop one frame by frame and send it to sort tracker
# read test data from disk in a loop one frame by frame and send it to sort tracker
for
i
in
range
(
400000
):
for
i
in
range
(
400000
):
# read frame image
# read frame image
bg
=
cv2
.
imread
(
path
+
'
\\
'
+
str
(
i
%
800
+
1
)
+
'.jpg'
)
bg
=
cv2
.
imread
(
path
+
'
/
'
+
str
(
i
%
800
+
1
)
+
'.jpg'
)
# rescale
# rescale
bg
=
cv2
.
resize
(
bg
,
(
int
(
1280
/
scale
),
int
(
720
/
scale
)))
bg
=
cv2
.
resize
(
bg
,
(
int
(
1280
/
scale
),
int
(
720
/
scale
)))
# read detection data in current frame
# read detection data in current frame
dets
=
[]
dets
=
[]
with
open
(
path
+
'
\\
'
+
str
(
i
%
800
+
1
)
+
'.txt'
)
as
txt
:
with
open
(
path
+
'
/
'
+
str
(
i
%
800
+
1
)
+
'.txt'
)
as
txt
:
lines
=
txt
.
readlines
()
lines
=
txt
.
readlines
()
for
line
in
lines
:
for
line
in
lines
:
items
=
line
.
split
(
' '
)
items
=
line
.
split
(
' '
)
...
@@ -83,7 +86,8 @@ if __name__ == '__main__':
...
@@ -83,7 +86,8 @@ if __name__ == '__main__':
right
=
float
(
items
[
3
])
right
=
float
(
items
[
3
])
bottom
=
float
(
items
[
4
])
bottom
=
float
(
items
[
4
])
dets
.
append
((
left
/
scale
,
top
/
scale
,
right
/
scale
,
bottom
/
scale
,
int
(
items
[
0
])))
dets
.
append
((
left
/
scale
,
top
/
scale
,
right
/
scale
,
bottom
/
scale
,
int
(
items
[
0
])))
# send to the tracker and draw the result on background image
# send to the tracker and draw the result on background image
if
len
(
dets
)
>
0
:
if
len
(
dets
)
>
0
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录